I know there are many "authentication" plugins and gems, but it would be just GREAT if you add all of "needed" basic gems to your one-stop nifty generators!
1. authentication w/ full functionalities
2. layout w/ decent style(s)
1 question:
I noticed your routes.db has
login path set to:"sessions" controller and "new" action
But your session controller does not have "new" action. It has a "create" action. Is it that rails matches "new"action to "create" action?
A little followup: I went back and tried this with Rails 2.3.5 and everything worked much better. I did have problems with the generator scripts; it seems like they aren't too tolerant of other ORM's. Once I got everything laid out though it worked brilliantly.
I did have problems with my database.yml file though; In your cast you don't empty it, but if I left database.yml populated with the sqlite information it would barf when I started the server. An empty database.yml made things much better.
Thanks for the great screencast Ryan! I made a little modification to distinguish JavaScript from HTML (or other) requests. That way you can respond nicely to AJAX requests on a mobile device (for example jQT.goBack() after a submitted form).
if mobile_device?
if request.format == :js
request.format = :mobilejs
else
request.format = :mobile
end
end
I was working on a similar example using Rails3.Beta and MongoMapper. The biggest difficulty I had was that the models no longer inherited from ActiveRecord, and it felt like I had to change things significantly to make things work.
For example I couldn't use "form_for @object" because it would complain that @object didn't have method 'foo' (in this case I believe it was missing 'class_name'). I could get form_tag to work, but the experience made me wonder how well mongomapper+mongodb will work as a straight replacement to AR.
Well, I re-watched your cast and noticed that you didn't have these problems with 2.3.x!! Hopefully I am doing something wrong on my end, but am going to try with 2.3.x right now..
Very exciting though, I'm hoping to use Rails+mongo for my next side project, thank you for covering it here.
very nice gem ryan, well done. However, does the gem now supports nested roles e.g. being able to declare one role as part of another role? This would be useful for situations like you a reader_guest, and an editor_guest; the editor_guest can then 'contain' the reader_guest.
Declarative auth supports this; but cancan is so much simpler. Thanks again
Some of the issues I've seen using rvm and ruby 1.9.2 on Mac OSX 10.5.8 - the first is a permissions issue where the .gem/cache directory has system and not <USER> (whoever you log in as) as the owner - chown /R .gem <USER>:staff .gem did the trick for me.
Second issue is a big crash in using 1.9.2-preview which is the default 1.9.2 install in rvm - doing rvm install ruby-1.9.2-head is reported to fix this: see https://rails.lighthouseapp.com/projects/8994/tickets/3669-ruby-192-and-rails-30pre-aborts-on-scriptgenerate
For those trying to get bundler working with existing Rails 2.3 applications, have a look at:
http://gist.github.com/302406
It took a little fiddling (and I discovered a few gem dependencies that were missing in my environment.rb) but the big Rails 2.3 application I'm developing is now working with bundler.
Hey Ryan. Great work! Can i ask u a question though , kinda stupid actually. But i was wondering how to combine will_paginate and searchlogic? if u could help me out that'll be great..
Great info here! I've been using iUI for a while, but I do like how you have this one set up.
Has anyone found any clever CSS to handle the errorExplanation div for mobile devices? It doesn't seem to stand out as much to me. I'll have to play a bit more with it. Any best practices when it comes to displaying errors in a mobile web app with rails?
Nice Thing, but it find_or_create_by won't work when you have validations on your category model for additional fields.
I tried to prefill them also, but accessing attributes from the form won't work.Creating a virtual attribute was no solution because then i would need to enter information twice.
Thanks for yet another great episode Ryan! Congrats on #200!!!
For anyone who is installing on Ubuntu 9.10, (and using 1.9.1, per the video) you might have to do what I did to get things going:
after you install rvm, but before doing anything else, do
rvm openssl
This might require other packages (like curl), so go get those. If you don't do this, everything in the install of rails 3.0.0beta will seem to be fine until you go to test your app, and the server will get errors about openssl being missing. (I also had to install sqlite3-ruby, but that's likely because I don't have it installed by default in my non rvm world). I think building ruby and possibly rails looks for the presence of openssl, and builds accordingly, so if you don't ensure it's installed before getting ruby 1.9.1, you will have to start over from scratch by removing the .rvm directory and following the video instructions from the beginning.
Anyone knowns how to validate the content of the checkbox? To ensure the user does not add unauthorized id? I can't find how to do that using validate_inclusion_of.
If you don't see it, go ahead and submit a patch and others will point you to the existing functionality if it's already implemented. If it's a larger patch, it's probably best to ask in the google group before attempting to implement it, to see if others would find it useful and if they have any ideas on the implementation.
@Marc Luzietti: I'm going crazy trying to set this up. Why is that rake file missing from the main repository. Even in the homepage for the project it says that you need that particular task "rake open_id_authentication:db:create".
Hey folks, Brad from Poll Everywhere here. We’re upgrading to bundler 0.9.5 and ran into a questions using Bundler with git.
First, should the .bundle folder be ignored? If so, there is an issue when another developer pulls a project and runs ‘bundle install’. The bundler gets to the end of the install process and blows up because .bundle/environment.rb is not found. The error messaging isn’t very clear around this problem either, but a ‘bundle lock’ command fixes it since the generates the .bundle folder. I’m positive that .bundle should be ignored in .git because it contains absolute paths to the gem files, so the bundle install command should probably generate this file if its not present.
@fred zingg: For real-time help i'd suggest using irc (freenode.net, #rubyonrails) - not knowing if irc-access to freenode is "censured". But have a look at http://rubyonrails.org/community
I should point out that checking in .bundle/config is a one time operation, and from this point on you can simple run bundle install, since bundler uses the config file from then on.
I've solved that problem by using the install path.
ie. I run:
bundle install vendor/bundle
in my rails root, then I check in the .bundle/config file which is generated. That way the gem files are always stored in a bundle local to the project as opposed to ~/.bundle
@Felipe, right, currently if you switch Ruby versions with rvm it will attempt to use the same .bundler gems which causes problems. This will be addressed in future versions of Bundler. It looks like the fix is already in the GitHub repo, so I'm guessing it will be in 0.9.6.
What about bundler and rvm? because bundler saves the gems in the .bundler directory instead in my rvm specific environment, i see that is incompatible, but i wish to use rvm with bundler, that i miss in this episode. Greetings
I tried the following code, the flash gets displayed, but the 'Product.find' is still getting executed resulting in the error :
"Couldn't find Product without an ID"
begin
rescue params[:product_ids].empty?
logger.error("No products selected for 'Edit Selected'" )
flash[:notice] = "Nothing selected for 'Edit Selected' action"
Currently, `gem install rails --pre` doesn't work as it cannot pull non-pre dependencies. There is a gem called 'rails3b' which you can gem install to get around this.
@Martinos, each user has their own cache, so you'll need to bundle install when switching users. You can also "bundle install /some/path" to change the location to a global one.
@David, @DGM Bundler does support Rails 2.3 but the experience is still being improved. See this gist for how to do it currently: http://gist.github.com/302406
@David, As for plugins vs gems. Plugins are still acceptable, but in Rails 3 there are fewer reasons to do a plugin over a gem since it's now easy to add engines and rake tasks into a gem. I like to use plugins for small, simple additions and gems for larger, full featured projects.
Going through the links from last week, I started in on the "5 Things You Can Do Today to Make Your App Ready for Rails 3" link from "Rails 3.0 Beta: 36 Links and Resources To Get You Going" and tried to install bundler for my rails 2.3 app.. but bundler has changed significantly since then.
This episode is great for getting the new syntax, but I'm wondering what the process is to get a rails 2.3 app to use the gems from bundler - I'm not sure if the original code posted is still accurate...
After spending some time going through the source I found that I can just define permission_denied on my controller and it will be called and I can do whatever I want! Problem solved!
http://rubyinstaller.org/download.html - Use the 1.8.7 mingw32-package.
http://github.com/vertiginous/pik instead of RVM.
After installation of the Rails pre-gem in your environment. Apply fix mentioned in https://rails.lighthouseapp.com/projects/8994/tickets/3861-script-replaced-by-scriptrails-not-working
And you're up and running on Windows without problems =)
I've still not checked out Rails 3 after these many days because I'm developing on a Windows machine. Hoping to set up an Ubuntu virtual OS to check out Rails3, RV and bundler.
Glad to see rails 3 related railscasts since episode 200.
You should use PHP :) No problems with JS, HTML and other things. You may create main Rails environment features within 2 hours if needed.
I know there are many "authentication" plugins and gems, but it would be just GREAT if you add all of "needed" basic gems to your one-stop nifty generators!
1. authentication w/ full functionalities
2. layout w/ decent style(s)
Thanks!!!!
I was also wondering if anyone has used the nested_form plugin with formtastic successfully?
Great tutorial as always, many thanks!
First, should the .bundle folder be ignored?
Hey Ryan,
Nice screencast.
1 question:
I noticed your routes.db has
login path set to:"sessions" controller and "new" action
But your session controller does not have "new" action. It has a "create" action. Is it that rails matches "new"action to "create" action?
Am I missing anything here? Thanks Abhi
A little followup: I went back and tried this with Rails 2.3.5 and everything worked much better. I did have problems with the generator scripts; it seems like they aren't too tolerant of other ORM's. Once I got everything laid out though it worked brilliantly.
I did have problems with my database.yml file though; In your cast you don't empty it, but if I left database.yml populated with the sqlite information it would barf when I started the server. An empty database.yml made things much better.
Thanks for the great screencast Ryan! I made a little modification to distinguish JavaScript from HTML (or other) requests. That way you can respond nicely to AJAX requests on a mobile device (for example jQT.goBack() after a submitted form).
if mobile_device?
if request.format == :js
request.format = :mobilejs
else
request.format = :mobile
end
end
http://gist.github.com/308804
I was working on a similar example using Rails3.Beta and MongoMapper. The biggest difficulty I had was that the models no longer inherited from ActiveRecord, and it felt like I had to change things significantly to make things work.
For example I couldn't use "form_for @object" because it would complain that @object didn't have method 'foo' (in this case I believe it was missing 'class_name'). I could get form_tag to work, but the experience made me wonder how well mongomapper+mongodb will work as a straight replacement to AR.
Well, I re-watched your cast and noticed that you didn't have these problems with 2.3.x!! Hopefully I am doing something wrong on my end, but am going to try with 2.3.x right now..
Very exciting though, I'm hoping to use Rails+mongo for my next side project, thank you for covering it here.
i have user and book model
very nice gem ryan, well done. However, does the gem now supports nested roles e.g. being able to declare one role as part of another role? This would be useful for situations like you a reader_guest, and an editor_guest; the editor_guest can then 'contain' the reader_guest.
Declarative auth supports this; but cancan is so much simpler. Thanks again
Belated congratulations!
I only wish all screencasts were as well made. :-)
THANK YOU!!!
FYI: Rails3 no longer has a link_to_function.
One option seems to be:
rails plugin install git://github.com/rails/prototype_legacy_helper.git
button_to_function is another option.
Sorry - type above: chown /R <USER>:staff .gem
Some of the issues I've seen using rvm and ruby 1.9.2 on Mac OSX 10.5.8 - the first is a permissions issue where the .gem/cache directory has system and not <USER> (whoever you log in as) as the owner - chown /R .gem <USER>:staff .gem did the trick for me.
Second issue is a big crash in using 1.9.2-preview which is the default 1.9.2 install in rvm - doing rvm install ruby-1.9.2-head is reported to fix this: see https://rails.lighthouseapp.com/projects/8994/tickets/3669-ruby-192-and-rails-30pre-aborts-on-scriptgenerate
Very nice screencast.
rvm >= 0.1.15 (rvm update --head) now has built in bundler support (via BUNDLE_PATH), keep an eye on the documentation page for updates:
http://rvm.beginrescueend.com/integration/bundler/
~Wayne
For those trying to get bundler working with existing Rails 2.3 applications, have a look at:
http://gist.github.com/302406
It took a little fiddling (and I discovered a few gem dependencies that were missing in my environment.rb) but the big Rails 2.3 application I'm developing is now working with bundler.
Hey Ryan. Great work! Can i ask u a question though , kinda stupid actually. But i was wondering how to combine will_paginate and searchlogic? if u could help me out that'll be great..
Super !
Great info here! I've been using iUI for a while, but I do like how you have this one set up.
Has anyone found any clever CSS to handle the errorExplanation div for mobile devices? It doesn't seem to stand out as much to me. I'll have to play a bit more with it. Any best practices when it comes to displaying errors in a mobile web app with rails?
Nice Thing, but it find_or_create_by won't work when you have validations on your category model for additional fields.
I tried to prefill them also, but accessing attributes from the form won't work.Creating a virtual attribute was no solution because then i would need to enter information twice.
Ok, so if you have <%= javascript_include_tag :defaults %> in your header along with the call to jquery, it will not work, FYI.
I've worked out a solution to this now.
You just need to add a (conditional) style to the "fields" div to set "display: none" if f.object._destroy
Steve, I have the same problem. <% javascript "pagination" %> does not call the script.
Thanks for yet another great episode Ryan! Congrats on #200!!!
For anyone who is installing on Ubuntu 9.10, (and using 1.9.1, per the video) you might have to do what I did to get things going:
after you install rvm, but before doing anything else, do
rvm openssl
This might require other packages (like curl), so go get those. If you don't do this, everything in the install of rails 3.0.0beta will seem to be fine until you go to test your app, and the server will get errors about openssl being missing. (I also had to install sqlite3-ruby, but that's likely because I don't have it installed by default in my non rvm world). I think building ruby and possibly rails looks for the presence of openssl, and builds accordingly, so if you don't ensure it's installed before getting ruby 1.9.1, you will have to start over from scratch by removing the .rvm directory and following the video instructions from the beginning.
Anyone knowns how to validate the content of the checkbox? To ensure the user does not add unauthorized id? I can't find how to do that using validate_inclusion_of.
If you don't see it, go ahead and submit a patch and others will point you to the existing functionality if it's already implemented. If it's a larger patch, it's probably best to ask in the google group before attempting to implement it, to see if others would find it useful and if they have any ideas on the implementation.
@Marc Luzietti: I'm going crazy trying to set this up. Why is that rake file missing from the main repository. Even in the homepage for the project it says that you need that particular task "rake open_id_authentication:db:create".
Hey folks, Brad from Poll Everywhere here. We’re upgrading to bundler 0.9.5 and ran into a questions using Bundler with git.
First, should the .bundle folder be ignored? If so, there is an issue when another developer pulls a project and runs ‘bundle install’. The bundler gets to the end of the install process and blows up because .bundle/environment.rb is not found. The error messaging isn’t very clear around this problem either, but a ‘bundle lock’ command fixes it since the generates the .bundle folder. I’m positive that .bundle should be ignored in .git because it contains absolute paths to the gem files, so the bundle install command should probably generate this file if its not present.
Hey Brian, are you aware that the video controls for your videos don't work in Chrome? Just fyi.
@fred zingg: For real-time help i'd suggest using irc (freenode.net, #rubyonrails) - not knowing if irc-access to freenode is "censured". But have a look at http://rubyonrails.org/community
I should point out that checking in .bundle/config is a one time operation, and from this point on you can simple run bundle install, since bundler uses the config file from then on.
@felipe and @ryan:
I've solved that problem by using the install path.
ie. I run:
bundle install vendor/bundle
in my rails root, then I check in the .bundle/config file which is generated. That way the gem files are always stored in a bundle local to the project as opposed to ~/.bundle
@Felipe, right, currently if you switch Ruby versions with rvm it will attempt to use the same .bundler gems which causes problems. This will be addressed in future versions of Bundler. It looks like the fix is already in the GitHub repo, so I'm guessing it will be in 0.9.6.
What about bundler and rvm? because bundler saves the gems in the .bundler directory instead in my rvm specific environment, i see that is incompatible, but i wish to use rvm with bundler, that i miss in this episode. Greetings
This episode is great for getting the new syntax.Since gems are installed in our home directory///
Ryan,
I tried the following code, the flash gets displayed, but the 'Product.find' is still getting executed resulting in the error :
"Couldn't find Product without an ID"
begin
rescue params[:product_ids].empty?
logger.error("No products selected for 'Edit Selected'" )
flash[:notice] = "Nothing selected for 'Edit Selected' action"
redirect_to products_path
end
@products = Product.find(params[:product_ids])
Ryan,
If you click 'Edit Checked' without anything checked you get a walkback:
Couldn't find Product without an ID
How do you trap that error / post an error message?
Mike
Currently, `gem install rails --pre` doesn't work as it cannot pull non-pre dependencies. There is a gem called 'rails3b' which you can gem install to get around this.
@Martinos, each user has their own cache, so you'll need to bundle install when switching users. You can also "bundle install /some/path" to change the location to a global one.
@David, @DGM Bundler does support Rails 2.3 but the experience is still being improved. See this gist for how to do it currently: http://gist.github.com/302406
@David, As for plugins vs gems. Plugins are still acceptable, but in Rails 3 there are fewer reasons to do a plugin over a gem since it's now easy to add engines and rake tasks into a gem. I like to use plugins for small, simple additions and gems for larger, full featured projects.
How do you deal with page caching when you have mobile views???
Going through the links from last week, I started in on the "5 Things You Can Do Today to Make Your App Ready for Rails 3" link from "Rails 3.0 Beta: 36 Links and Resources To Get You Going" and tried to install bundler for my rails 2.3 app.. but bundler has changed significantly since then.
This episode is great for getting the new syntax, but I'm wondering what the process is to get a rails 2.3 app to use the gems from bundler - I'm not sure if the original code posted is still accurate...
After spending some time going through the source I found that I can just define permission_denied on my controller and it will be called and I can do whatever I want! Problem solved!
Ryan,
Your 'casts are wonderful. I've only been developing in Ruby and Rails for about 2 months, and would not have gotten as far without them.
2 questions:
Because I am such a rookie, I have been reticent to go to 3. Does bundler work' with 2?
(this one may be off-topic) Tryitng to get my head around gems vs plugins. Are plugins not recommended in 3?
Thanks,
dc
Hi!
Excelent work Ryan!
Congratulations for the 200th episode
Still very useful screencast.
Since gems are installed in our home directory, how would we manage an application shared amongst many users ?
Thank you Ryan work your great work.
@Nithin Bekal
No need for setting up an Ubuntu virtual os.
http://rubyinstaller.org/download.html - Use the 1.8.7 mingw32-package.
http://github.com/vertiginous/pik instead of RVM.
After installation of the Rails pre-gem in your environment. Apply fix mentioned in https://rails.lighthouseapp.com/projects/8994/tickets/3861-script-replaced-by-scriptrails-not-working
And you're up and running on Windows without problems =)
I've still not checked out Rails 3 after these many days because I'm developing on a Windows machine. Hoping to set up an Ubuntu virtual OS to check out Rails3, RV and bundler.
Glad to see rails 3 related railscasts since episode 200.
Great as always Ryan. Didn't know about the "without" or "lock" options. Thanks!
hi Ryan
Is there any method for Automated Recurring payment for paypal with Active merchant plugin?
If yes please post some helpful links.
thanks
Just what i was looking for!
Once I implemented this, I now do not get redirected to the correct page after submit. Should i put the redirect page path into the model def?