I'm also having an issue with my model that contains a has_many :through association.
It would be nice to see this approached in the video... though that might be asking too much in your scope of the tutorial.
EDIT: I actually don't have a problem with my has_many :through... it works fine. I found that my coffescript had its indents wrong and was throwing an error. Once the coffeescript was fixed everything works like a charm.
Authorization and mass assignment protection can reasonably be moved to a controller and actually makes more sense there in many cases. Model validations should reside in the model or you risk having inconsistent data. Having different validations based on state of your model isn't all that hacky or uncommon, though it does require rigor to set that state variable re: https://github.com/schneems/wicked/wiki/Partial-Validation-of-Active-Record-Objects
Hi. I'm one of the rubber devs. It can handle non-Rails applications just fine. I've personally deployed a couple Sinatra apps with in. And I even use Rubber to manage a few servers that just run Java apps and quite a few Windows machines on EC 2 (note that Rubber can only create/destroy/reboot Windows -- no app deploy).
It is currently EC 2 only. Part of the rubber 2 revamp was to base it on fog, which opens up the opportunity to run on a lot more providers. But, as of yet, we haven't done the work to finish this up. It's on the docket though.
I would recommend just directing a user to an after register flow rather than over-riding the create method totally, i've tried both, and it will cause you less pain.
Thank you for this very nice cast. Rubber is impressive and makes great use of Capistrano's power. Can it handle non-rails applications and other cloud providers (I am guessing no and no)?
I've done all these things in the past year so I'll pitch in.
The best part of using ec2's is you can get your servers to a stateless point. Where you can drop your existing servers at the drop of the hat if they have redundancies.
If you were to have a web, app, db server. to split that up you'd start by setting up a new db server where it's solely db and dump your current db over there. I personally love using RDS so I always have a separate db setup to host and I never have to worry about it. Alternatively, you could setup a slave on a separate server and then promote it later.
You can then set up more separate app servers, which become part of the network so they'll be managing some load but still working with the web role on the original server.
Finally, you can pull out the web role into it's own and the two web servers will work fine and you can drop one seamlessly.
Auto scaling is a bit different. Amazon does have ways of flashing your current image and they'll start up a new one if certain requirements are met. I haven't played with this as much. As long as you're paying attention, you can scale yourself really quickly in rubber without any new configuratio.
Staging environment is just like any rails env. set up a new staging.rb file in the environments and when you do cap rubber:create_staging, prefix it with RUBBER_ENV=staging cap rubber:create_staging so it setups up an entire rubber configuration within that environment. Separates out the instance yaml's and everything.
I get this itchy feeling any time the model has to know what the controller is doing. Validation of the sort needed to get the field validation working always seem kind of hacky to me. I know there's been a few debates, but I tend to favor the side that saying validation should be moved to the controller because it already hooked into things like context and state (i.e. authorization).
(This does not mean this wasn't another great Railscast.)
Solved! I received some help on this. I figured it had something to do with environment variables getting lost, and I was right. unicorn needs to have an rvm ruby wrapper around it, by executing:
rvm wrapper 1.9.3 ruby-1.9.3 unicorn
and it creates a new init script to run called:
ruby-1.9.3_unicorn
afterwards you'll need to modify the unicorn_init.sh $CMD to read something like:
/usr/local/rvm/bin/ruby-1.9.3_unicorn -D -c $APP_ROOT/config/unicorn.rb -E production
I haven't watched the episode yet but I wouldn't see why not. SSH is standard for any linux setup I've worked with. Also typically Capistrano uses it for tunneling.
Thanks for the reply. It might sound silly, but can you access the server via ssh? I haven't tried it yet, but I am considering moving my application to EC2.
If you start of with a small app so only one server required for all roles how well does rubber handle breaking this up once hopefully you start to get bigger. ie creating separate roes for App, Web & DB.
Would you have to convert your existing role to be just DB??
Also what about auto scaling. Is there a way to have rubber auto scale app and db slave servers if required?
And one more to chuck in what about setting up staging environment?
But like Alexander has said this seems a great tool.
First off, make sure you have rmagick in your gemfile.
Then in your rubber.yml file there should be a setting for 'packages'. Somewhere around line 189. You can simply add aptitude packages in this array.
Add to the array, 'imagemagick' and possibly libmagick9-dev. Simply cap rubber:bootstrap your instance and it will install these packages for you along with the new gem in your gemfile. Paperclip and other image processing should be good to go.
Note, you can also install packages on a template by template basis. Like only installing imagemagick when you are using passenger etc. The rubber.yml packages line will install it on all your severs.
Do you have experience with installing RMagick with Rubber on an instance? What is the best way to do it? I can simply ssh to the instance and install it manually, but it doesn't feel right.
Ah yes. Oracle.... Oracle certainly has these features and more. However, I typically exclude Oracle from comparisons when talking about Ruby related programming. Oracle has so many features but they are out of reach for simple projects that exist in a non-enterprise environment.
The simple aspect that my experience lends is just a very scalable system. With rubber, I have roles for each aspect of my application and spinning up a new server to handle more application resources takes minutes. Interfacing ec2's with other amazon services is ridiculously easy. Scaling horizontally and vertically is simplified especially with tools like Rubber.
Yes. Rubber hooks into capistrano and installs all the packages that are needed for the given template. Adding more aptitude packages is easy and all contained within the Rubber config files.
splitting up the web app and db instances in rubber is more about how Rubber handles 'roles'. There can also be a redis role, a resque role, a sphinx role etc. It allows rubber to be very modular and scalable. You can place different roles on different hardware for instance.
Thanks Brian, for breaking the noobish question ice. Here's another one: Would anybody care to weigh in on the pros & cons of this EC2 service vs. using a VPS? Or maybe offer a link to an article that hits this question?
Sorry if this is a noobish question, but why is the application being split into web, app, and db instances? I don't really understand that part. Is that just for Amazon or cloud-based load balancing, or is that something that I should be doing on a VPS? Thanks
Now there's a problem with Simple Navigation - when I follow to next step (when user_steps_controller.rb runs) simple_navigation somehow forgots all the "global" variables like root_path etc., so that I get error in application layout
ruby
undefined local variable or method `root_path' for "user_steps":String
I'd like to add, that simply adding root_path in application layout works, so there's something wrong with =render_navigation.
If anyone uses those 2 gems and somehow solved this problem, please share. :)
I've wrote rails engine https://github.com/vlado/rails_temporary_data that could be low level alternative when you have complex validations.
It just gives you helpers to easily save and manipulate temporary data (saved in separate table as serialized attribute) till you finish all steps (you'll need to define steps yourself).
I think it could even be useful in combination with wicked.
Thanks for the screencast. it's an Interesting subject.
Usually I love your Railscasts but I feel this one was a bit rushed. The screens changed too quickly.
I was disappointed when you skipped the validations as it's the harder part.
The partial layout at end seems interesting and deserve a full episode on when to use it.
NOOB - Getting error
* executing "sudo -p 'sudo password: ' bash -l -c 'cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'"
servers: ["50.17.145.140"]
.. ** Failed to connect to 50.17.145.140, retrying
* executing `rubber:_allow_root_ssh'
I believe my credentials are correct.
If I look at the EC2 console it says the private ip is 10.111.63.18
I'm also having an issue with my model that contains a has_many :through association.
It would be nice to see this approached in the video... though that might be asking too much in your scope of the tutorial.
EDIT: I actually don't have a problem with my has_many :through... it works fine. I found that my coffescript had its indents wrong and was throwing an error. Once the coffeescript was fixed everything works like a charm.
thanks for your good work!
NOOB - when I'm creating the EC2 instance, Amazon wants me to select a AMI (stack). Which one do you select?
Nice!
Authorization and mass assignment protection can reasonably be moved to a controller and actually makes more sense there in many cases. Model validations should reside in the model or you risk having inconsistent data. Having different validations based on state of your model isn't all that hacky or uncommon, though it does require rigor to set that state variable re: https://github.com/schneems/wicked/wiki/Partial-Validation-of-Active-Record-Objects
Hi. I'm one of the rubber devs. It can handle non-Rails applications just fine. I've personally deployed a couple Sinatra apps with in. And I even use Rubber to manage a few servers that just run Java apps and quite a few Windows machines on EC 2 (note that Rubber can only create/destroy/reboot Windows -- no app deploy).
It is currently EC 2 only. Part of the rubber 2 revamp was to base it on fog, which opens up the opportunity to run on a lot more providers. But, as of yet, we haven't done the work to finish this up. It's on the docket though.
I would recommend just directing a user to an after register flow rather than over-riding the create method totally, i've tried both, and it will cause you less pain.
Let me know if you have problems with validations
*cease :)
Thanks Scott, Going to give rubber a go I recon.
9 months bump.....
I also have this problem
Thank you for this very nice cast. Rubber is impressive and makes great use of Capistrano's power. Can it handle non-rails applications and other cloud providers (I am guessing no and no)?
+1 with awesome_nested_fields. It's got very detailed wiki
In Rails 3.0.3 I get "undefined method `klass'" from the application_helper.
This is the syntax I'm using:
Is my syntax correct? Does "klass" work with my rails version?
Thanks
I've done all these things in the past year so I'll pitch in.
The best part of using ec2's is you can get your servers to a stateless point. Where you can drop your existing servers at the drop of the hat if they have redundancies.
If you were to have a web, app, db server. to split that up you'd start by setting up a new db server where it's solely db and dump your current db over there. I personally love using RDS so I always have a separate db setup to host and I never have to worry about it. Alternatively, you could setup a slave on a separate server and then promote it later.
You can then set up more separate app servers, which become part of the network so they'll be managing some load but still working with the web role on the original server.
Finally, you can pull out the web role into it's own and the two web servers will work fine and you can drop one seamlessly.
Auto scaling is a bit different. Amazon does have ways of flashing your current image and they'll start up a new one if certain requirements are met. I haven't played with this as much. As long as you're paying attention, you can scale yourself really quickly in rubber without any new configuratio.
Staging environment is just like any rails env. set up a new staging.rb file in the environments and when you do cap rubber:create_staging, prefix it with RUBBER_ENV=staging cap rubber:create_staging so it setups up an entire rubber configuration within that environment. Separates out the instance yaml's and everything.
Yea! That's my favorite part of rubber, it doesn't abstract anything away from you.
tunneling in, use your ec2 keypair and ssh root@name, i.e.: ssh -i ~/.ec2/gsg-keypair root@app01.foo.com
Once you're in, you can find all your config files where they're supposed to be or your app in the /mnt directory.
I get this itchy feeling any time the model has to know what the controller is doing. Validation of the sort needed to get the field validation working always seem kind of hacky to me. I know there's been a few debates, but I tend to favor the side that saying validation should be moved to the controller because it already hooked into things like context and state (i.e. authorization).
(This does not mean this wasn't another great Railscast.)
Solved! I received some help on this. I figured it had something to do with environment variables getting lost, and I was right. unicorn needs to have an rvm ruby wrapper around it, by executing:
rvm wrapper 1.9.3 ruby-1.9.3 unicorn
and it creates a new init script to run called:
ruby-1.9.3_unicorn
afterwards you'll need to modify the unicorn_init.sh $CMD to read something like:
/usr/local/rvm/bin/ruby-1.9.3_unicorn -D -c $APP_ROOT/config/unicorn.rb -E production
See http://stackoverflow.com/questions/10454292/ubuntu-12-04-unicorn-init-sh-start-works-but-service-unicorn-init-start-do for more info.
Try
bundle exec cap deploy:setup
.I haven't watched the episode yet but I wouldn't see why not. SSH is standard for any linux setup I've worked with. Also typically Capistrano uses it for tunneling.
Thanks for the reply. It might sound silly, but can you access the server via ssh? I haven't tried it yet, but I am considering moving my application to EC2.
Thanks again.
Ill add another new question re rubber.
If you start of with a small app so only one server required for all roles how well does rubber handle breaking this up once hopefully you start to get bigger. ie creating separate roes for App, Web & DB.
Would you have to convert your existing role to be just DB??
Also what about auto scaling. Is there a way to have rubber auto scale app and db slave servers if required?
And one more to chuck in what about setting up staging environment?
But like Alexander has said this seems a great tool.
Thank you very much, Scott!
I had to add "libmagickwand-dev" as well to make it work.
Rubber seems to be a really great tool :)
Wow, that's really sweet.
Thanks for the help.
There's a much better way.
First off, make sure you have rmagick in your gemfile.
Then in your rubber.yml file there should be a setting for 'packages'. Somewhere around line 189. You can simply add aptitude packages in this array.
Add to the array, 'imagemagick' and possibly libmagick9-dev. Simply cap rubber:bootstrap your instance and it will install these packages for you along with the new gem in your gemfile. Paperclip and other image processing should be good to go.
Also. There's a wealth of rubber information on the google discussion group from the last few years. http://groups.google.com/group/rubber-ec2
Note, you can also install packages on a template by template basis. Like only installing imagemagick when you are using passenger etc. The rubber.yml packages line will install it on all your severs.
Okay, thanks Scott.
Do you have experience with installing RMagick with Rubber on an instance? What is the best way to do it? I can simply ssh to the instance and install it manually, but it doesn't feel right.
Ah yes. Oracle.... Oracle certainly has these features and more. However, I typically exclude Oracle from comparisons when talking about Ruby related programming. Oracle has so many features but they are out of reach for simple projects that exist in a non-enterprise environment.
The best way would be to add a rubber template to the mix. You can check out the existing templates here: https://github.com/wr0ngway/rubber/tree/master/templates
Another method would be to simply spin up a server with rubber, ssh in and setup faye manually.
This is a big topic.
The simple aspect that my experience lends is just a very scalable system. With rubber, I have roles for each aspect of my application and spinning up a new server to handle more application resources takes minutes. Interfacing ec2's with other amazon services is ridiculously easy. Scaling horizontally and vertically is simplified especially with tools like Rubber.
Yes. Rubber hooks into capistrano and installs all the packages that are needed for the given template. Adding more aptitude packages is easy and all contained within the Rubber config files.
splitting up the web app and db instances in rubber is more about how Rubber handles 'roles'. There can also be a redis role, a resque role, a sphinx role etc. It allows rubber to be very modular and scalable. You can place different roles on different hardware for instance.
I've been using Rubber for a bit over a year now and absolutely love it. Version 2.0 is a huge improvement as well.
Thanks Brian, for breaking the noobish question ice. Here's another one: Would anybody care to weigh in on the pros & cons of this EC2 service vs. using a VPS? Or maybe offer a link to an article that hits this question?
Thanks everybody and thanks again Ryan.
Very nice info!
Sorry if this is a noobish question, but why is the application being split into web, app, and db instances? I don't really understand that part. Is that just for Amazon or cloud-based load balancing, or is that something that I should be doing on a VPS? Thanks
Awesome!
Hey, Ryan, thanks for the episode!
This may be a silly question, but does rubber also install all we need in the EC2 to deploy?
Thanks in advance.
Yeh, thank you.
Now there's a problem with Simple Navigation - when I follow to next step (when user_steps_controller.rb runs) simple_navigation somehow forgots all the "global" variables like root_path etc., so that I get error in application layout
I'd like to add, that simply adding root_path in application layout works, so there's something wrong with =render_navigation.
If anyone uses those 2 gems and somehow solved this problem, please share. :)
Did you see here? https://github.com/plataformatec/devise/wiki/_pages
Hello!
Why rbenv, not rvm ??
And generally how to implement it correctly in Devise?
Any idea how to overwrite create method in Devise (code in users_controller.rb)?
He just want to save the bandwidth ;-)
Nice episode, but I have a simple question. How can I add a Faye server (or any other independent server) to the application?
Thanks,
Andrei
I've wrote rails engine https://github.com/vlado/rails_temporary_data that could be low level alternative when you have complex validations.
It just gives you helpers to easily save and manipulate temporary data (saved in separate table as serialized attribute) till you finish all steps (you'll need to define steps yourself).
I think it could even be useful in combination with wicked.
That was one of the best episodes yet. Thank you so much.
Excellent episode, thank you
Thanks for the screencast. it's an Interesting subject.
Usually I love your Railscasts but I feel this one was a bit rushed. The screens changed too quickly.
I was disappointed when you skipped the validations as it's the harder part.
The partial layout at end seems interesting and deserve a full episode on when to use it.
Was just in the process of building wizard forms at work, you never seize to impress Ryan