P.S. Switching from Beta 2 to Beta 3 actually showed DEPRECATION WARNING when starting up the server or running RSpec specs.
DEPRECATION WARNING: ActionController::Base.cookie_verifier_secret= is deprecated. Please configure it on your application with config.secret_token=.
DEPRECATION WARNING: ActionController::Base.session= is deprecated. Please configure it on your application with config.session_store :cookie_store, :key => '....'.
I guess if you generate Rails app fresh with Beta 3, there is no error any more.
I tried Devise with Ruby on Rails 3.0 beta 3 and the gotcha mentioned in the screencast turned out to be with config.secret_token.
So with beta 3, you can leave cookie_verification_secret.rb untouched and you have to add config.secret_token to application.rb, e.g. .config.secret_token = 'secret'
I'm guessing that you are running Rails 2.x. Assuming that you installed the correct Devise gem (1.0.6) and are still getting the error:
`load_missing_constant': uninitialized constant Devise (NameError)
You probably are missing a couple of dependencies in your environment.rb file.
So, do the controllers stay locked away in the gem? If I wanted to protect the password during transmission using SSL (e.g., ssl_requirement), how would I do that? Make a copy of the controller in the gem to add the ssl_requirement code? Or is there a better way?
@Ryan N. What version of Rails are you running? If you are running 3.0, then you have to change from script/generate to rails generate with the rest of the arguments and flags included if you need etc., but if not, then I think you have to have different gem Devise version for Rails 2.3.5... Also, make sure to have dependency. When you first run the app, the app needs to load all of those gems that are, or should be, part of the app... Hope this helps.
Hi, was just going thru this tutorial. All is fine but when I try to render the nested forms for the questions or answers in the main form, I get an error saying unable to find template /surveys/_questions_form.rb
Logs dont tell much except it points to the line which is calling the render.
I am not sure of the resource.map and how it works but is there something else I need to do to render correctly?
I have an issue where my group_by list has numbers and alpha characters so it's sorting like this:
10
2
bakery
produce
but I want it to sort
2
10
bakery
produce
<% @items_aisles.keys.sort.each do |aisle| %>
so i found a place where someone said you could do :order => '0 + name ASC' etc but that's not relevant in this context. So I'm perplexed. Any help? Thanks.
I am trying to build a community where users can create leagues and join each others leagues. I would like to create a feature were people could go to http://localhost/league/1/join and there would be a join button. Upon pressing the join button, the rails application would insert into the leagues_users table, league_id = 1 and user_id = current_user.id.
I have attached my league.rb, user.rb and routes.rb files below.
Great railscast as always! As a beginner, they really make the learning curve more comfortable :)
Would love to see you make a cast about integrating Facebook Connect with Devise using devise_facebook_connectable. Somehow I can't figure out what I'm doing wrong. I've followed every step, but <%= facebook_link :user %> does not even work as intended. Anyone know of any tutorials other than the official one?
I like getting rid of the magic methods, but supplying a hash for subject, from, etc. seems like quite a step backwards for an API, especially considering the changes to AR query API (hash keys became methods).
Ryan, this screencast is awesome like any other screencast. I am a java/flex programmer, want to do rails. Learning a lot of tips/tricks from these posts. I wait for your posts every week. Thanks a lot again.
Do you have any recommendations for how to mock the OpenSSL methods so that paypal_encrypted can be tested? They produce different output with repeated invocations with identical input.
On a whim I tried mocking Kernel.rand, Kernal#rand, and Time.now, but that didn't help. I suppose I could dive head first into the OpenSSL code but wanted to first check if you had any pointers on how todo this.
Thanks for the fantastic and helpful episode, as usual.
Guys, can we please stop talking about Rails 3? It's still in BETA.
Let's just concentrate on rails 2.3.x? It's what we are all using and Ryan, I am sure everyone here will appreaciate your coverage on rails 2.3.x.
"The customizations were so basic that it doesn't deserve a cast."
@Samir the screencast may be basic to you but as one of Devise's developers I have to completely disagree with the affirmation above in the general sense.
Things like customizing the username is one of the most asked things in the mailing list and Ryan Bates shows how it can be done better than anyone could describe in an e-mail in Devise's mailing list.
Rails engines are new and even the basic questions, adding links to the layout showed in the previous screencast were already asked in the mailing list. So a big +1 for Ryan's work!
Hi all!
Based on this screeencast, a really noob/beginner/dumb question:
How would you make the "edit", "destroy" and "new project" link to only appear if the user is authenticated?
Big thx and btw, awesome screencasts!
Does removing the :registerable disable the sign up form? I was looking to only have the sign up for accessible to admins but I was just curious to any of you guys knew off the top of your head.
@ Samir - Beggers can't be picky.
@Railscasts Fan +1
From cast 1 to now I have seen a lot of improvement in how the casts are organized and edited; however, they have also become increasingly obfuscated, must have cascaded from scaffolding.
@Greg, as you probably realized, Devise is for authentication (user logins) and CanCan is for authorization (user permissions) - both can be used together and don't really overlap.
Devise does have the ability to make a separate model for each role, but I generally prefer to keep them all in the User model and handle roles through either booleans or an associated table. Here's an example.
I had taken a look at devise before, but stumbled on the documentation. Your screencasts are just the catalyst I needed to get going.
I often find this is the case with your 'casts. They are a great way of getting "oriented" around some new features and/or gems. In that way, they are extremely successful for someone like myself who really needs some initial hand holding and visual reinforcement before gaining sufficient confidence to jump into the official documentation.
I'm working on a project that will require three diff permissions groups. It looks like the devise way of doing things will require three different models. This seems silly to me... Can somebody point me in the right direction? Should I dump devise for something like cancan? I was really hoping Ryan would cover roles/permissions today.. Thanks in advance. And thank you for the free casts Ryan!
All I can add to my earlier note is what JValim posted on twitter "It's awesome how @rbates addresses in Devise's screencasts all frequent doubts people usually have on the mailing list".
For me Railscasts has always been about learning new things, tips and tricks. But also extending knowledge, clarifying things being unclear and work as a resource when coding.
Plenty of times I've come back to the casts to be reminded of things I've forgot. It's a great resource after all :)
If your next episode would also cover how to replace an existing install of authlogic, that would be great. I've been looking to replace it for awhile now. Also, one feature I find particularly useful in these tools is the ability to impersonate a user so if that exists, it would be nice to hear of too.
just to let you know that I've build a new syntax highlighting engine in Ruby. It's called Prism and you'll find it here: http://github.com/kib2/Prism.
I've also made a little pastebin with it : http://prism-pastebin.heroku.com/.
The sample you gave renders the following: http://prism-pastebin.heroku.com/13
@Alexis
You may want to check out the method `after_sign_in_path_for` in the devise documentation.
http://rdoc.info/projects/plataformatec/devise
Hope this helps a little. :)
I managed to get it working by commenting out the 'map.connect' lines at the bottom of the routes.rb file
After I run "script/server devise User" and try to view any controller it throws the error message:
"Routing Error
No route matches "/" with {:method=>:get}"
This is a paste of the routes.rb file of the very simple project I was testing devise on ( http://slexy.org/view/s21I0JCOdA )
Has anyone else run across this and managed to rectify it? If so. Please let me know! Any feedback is greatly appreciated.
P.S. Switching from Beta 2 to Beta 3 actually showed DEPRECATION WARNING when starting up the server or running RSpec specs.
DEPRECATION WARNING: ActionController::Base.cookie_verifier_secret= is deprecated. Please configure it on your application with config.secret_token=.
DEPRECATION WARNING: ActionController::Base.session= is deprecated. Please configure it on your application with config.session_store :cookie_store, :key => '....'.
I guess if you generate Rails app fresh with Beta 3, there is no error any more.
I tried Devise with Ruby on Rails 3.0 beta 3 and the gotcha mentioned in the screencast turned out to be with config.secret_token.
So with beta 3, you can leave cookie_verification_secret.rb untouched and you have to add config.secret_token to application.rb, e.g. .config.secret_token = 'secret'
Just to say a big thank you and to report that the code works great on Rails 2.2.2.
Thanks again.
Ryan N -
I'm guessing that you are running Rails 2.x. Assuming that you installed the correct Devise gem (1.0.6) and are still getting the error:
`load_missing_constant': uninitialized constant Devise (NameError)
You probably are missing a couple of dependencies in your environment.rb file.
config.gem 'warden'
config.gem 'devise'
Does someone knows how to implement FCKeditor on a nested attribute?
I did this for Authorize.net and it was pretty simple.
How'd you get syntax highlighting for the Gemfile? I've searched everywhere for a TMBundle and can't find out
Just saw your comment today :). I'll give it a try, thanks!
thanks
So, do the controllers stay locked away in the gem? If I wanted to protect the password during transmission using SSL (e.g., ssl_requirement), how would I do that? Make a copy of the controller in the gem to add the ssl_requirement code? Or is there a better way?
Hello, Thanks for the post.
Im using a different action from Index, and when I click on the pages it doesnt go to my "custom_action.js.erb"
@39 - I tried with the format.js, but i have to take out format.html and format.xml to force it to get the script, but it doesnt work either...
Why is so hard to code when the action is not Index?
Thanks!
@Ryan N. What version of Rails are you running? If you are running 3.0, then you have to change from script/generate to rails generate with the rest of the arguments and flags included if you need etc., but if not, then I think you have to have different gem Devise version for Rails 2.3.5... Also, make sure to have dependency. When you first run the app, the app needs to load all of those gems that are, or should be, part of the app... Hope this helps.
@supriya
ad this in the environment:
Paperclip.options[:swallow_stderr] = false
if you get sth like: -crop *x*y+*w*h-
false argument. try to add an whitespace at the end of the processor command
in the crop_command method:
" -crop '#{target.crop_w.to_i}x#{target.crop_h.to_i}+#{target.crop_x.to_i}+#{target.crop_y.to_i}' "
in lib/paperclip_processors/cropper.rb
Hi, was just going thru this tutorial. All is fine but when I try to render the nested forms for the questions or answers in the main form, I get an error saying unable to find template /surveys/_questions_form.rb
Logs dont tell much except it points to the line which is calling the render.
I am not sure of the resource.map and how it works but is there something else I need to do to render correctly?
I am running Rails 2.3.5
I have an issue where my group_by list has numbers and alpha characters so it's sorting like this:
10
2
bakery
produce
but I want it to sort
2
10
bakery
produce
<% @items_aisles.keys.sort.each do |aisle| %>
so i found a place where someone said you could do :order => '0 + name ASC' etc but that's not relevant in this context. So I'm perplexed. Any help? Thanks.
Ryan, love the screencasts, learned a lot!
Ryan -
I am trying to build a community where users can create leagues and join each others leagues. I would like to create a feature were people could go to http://localhost/league/1/join and there would be a join button. Upon pressing the join button, the rails application would insert into the leagues_users table, league_id = 1 and user_id = current_user.id.
I have attached my league.rb, user.rb and routes.rb files below.
Thoughts?
-------------------
FILE: league.rb
-------------------
class League < ActiveRecord::Base
has_and_belongs_to_many :users
end
------------------
FILE: user.rb
------------------
class User < ActiveRecord::Base
acts_as_authentic
has_and_belongs_to_many :leagues
end
------------------
routes.rb
------------------
map.resources :leagues, :member => { :join => :get }
And nested attributes is also currently broken:
https://rails.lighthouseapp.com/projects/8994/tickets/4242-nested-child-only-updates-if-parent-changes
Note: link_to_add_fields doesn't work in rails3.
check http://pastie.org/928690 for fix. basically fields_for no longer returns the rendered data.
Ryan:
Seeing that I absolutely love your CanCan gem, how would you recommend going about using CanCan with Devise.
One big problem I'm having is having Devise redirect to a stored location after a user logs in.
I believe that Devise has built-in "stored_location" functionality, but I can't for the life of me figure out how to use it.
The "redirect_to_target_or_default" and "store_target_location" methods of the authlogic gem obviously don't work.
Great railscast as always! As a beginner, they really make the learning curve more comfortable :)
Would love to see you make a cast about integrating Facebook Connect with Devise using devise_facebook_connectable. Somehow I can't figure out what I'm doing wrong. I've followed every step, but <%= facebook_link :user %> does not even work as intended. Anyone know of any tutorials other than the official one?
Great stuff.. just starting to play with devise... Feels very foreign from Authlogic though
Had to checkout the code and look through it all to actually know what methods it overrides
Any good sites that provides info on how to do more indepth customizations?
I like getting rid of the magic methods, but supplying a hash for subject, from, etc. seems like quite a step backwards for an API, especially considering the changes to AR query API (hash keys became methods).
Ryan (or anyone),
I am getting this error when running script/generate devise User
`load_missing_constant': uninitialized constant Devise (NameError)
Also, once I run the devise_install generator I can no longer start my server as I get the same error.
I know I just gotta be missing that one thing ...
Thanks in advanced.
Ryan, this screencast is awesome like any other screencast. I am a java/flex programmer, want to do rails. Learning a lot of tips/tricks from these posts. I wait for your posts every week. Thanks a lot again.
What do I do to display in the #show?
Right now, it shows empty. And I cannot use the virtual attribute. Should that be working?
Do you have any recommendations for how to mock the OpenSSL methods so that paypal_encrypted can be tested? They produce different output with repeated invocations with identical input.
On a whim I tried mocking Kernel.rand, Kernal#rand, and Time.now, but that didn't help. I suppose I could dive head first into the OpenSSL code but wanted to first check if you had any pointers on how todo this.
Thanks for the fantastic and helpful episode, as usual.
John
Guys, can we please stop talking about Rails 3? It's still in BETA.
Let's just concentrate on rails 2.3.x? It's what we are all using and Ryan, I am sure everyone here will appreaciate your coverage on rails 2.3.x.
thanks
"The customizations were so basic that it doesn't deserve a cast."
@Samir the screencast may be basic to you but as one of Devise's developers I have to completely disagree with the affirmation above in the general sense.
Things like customizing the username is one of the most asked things in the mailing list and Ryan Bates shows how it can be done better than anyone could describe in an e-mail in Devise's mailing list.
Rails engines are new and even the basic questions, adding links to the layout showed in the previous screencast were already asked in the mailing list. So a big +1 for Ryan's work!
@Branden
Removing the :registerable even removes all routes related to registration. Thus, you are not able to access the sign up form.
yeee...nevermind, i found that there is a helper method to verify if the user is signed in, "user_signed_in?".
Hi all!
Based on this screeencast, a really noob/beginner/dumb question:
How would you make the "edit", "destroy" and "new project" link to only appear if the user is authenticated?
Big thx and btw, awesome screencasts!
Does removing the :registerable disable the sign up form? I was looking to only have the sign up for accessible to admins but I was just curious to any of you guys knew off the top of your head.
The final piece of the administration puzzle: authentication. There are many different approaches which is why I saved this step for last. Thi
@ Samir - Beggers can't be picky.
@Railscasts Fan +1
From cast 1 to now I have seen a lot of improvement in how the casts are organized and edited; however, they have also become increasingly obfuscated, must have cascaded from scaffolding.
@Greg, as you probably realized, Devise is for authentication (user logins) and CanCan is for authorization (user permissions) - both can be used together and don't really overlap.
Devise does have the ability to make a separate model for each role, but I generally prefer to keep them all in the User model and handle roles through either booleans or an associated table. Here's an example.
http://wiki.github.com/ryanb/cancan/role-based-authorization
@Patrick, See the "Configuring Controllers" section in the Devise readme. If that doesn't work I encourage you to post on their mailing list.
http://groups.google.com/group/plataformatec-devise
That said, you may not need to change the controller in order to add nested form fields. See episodes #196 and #197 for an example.
Hi Ryan, great screenscast. I've been wondering how could I replace restful_authentication plugin with Devise plugin in a clean way. Any ideas ?
Не слабо!!!
Does anybody have any examples on how to roll a replacement register controller for devise?
That is what is needed as I understand it to add a nested form in the view.
Nevermind! Looks like I can combine Devise and CanCan. Thanks again!
Thanks Ryan. This is really helpful.
I had taken a look at devise before, but stumbled on the documentation. Your screencasts are just the catalyst I needed to get going.
I often find this is the case with your 'casts. They are a great way of getting "oriented" around some new features and/or gems. In that way, they are extremely successful for someone like myself who really needs some initial hand holding and visual reinforcement before gaining sufficient confidence to jump into the official documentation.
I'm working on a project that will require three diff permissions groups. It looks like the devise way of doing things will require three different models. This seems silly to me... Can somebody point me in the right direction? Should I dump devise for something like cancan? I was really hoping Ryan would cover roles/permissions today.. Thanks in advance. And thank you for the free casts Ryan!
All I can add to my earlier note is what JValim posted on twitter "It's awesome how @rbates addresses in Devise's screencasts all frequent doubts people usually have on the mailing list".
For me Railscasts has always been about learning new things, tips and tricks. But also extending knowledge, clarifying things being unclear and work as a resource when coding.
Plenty of times I've come back to the casts to be reminded of things I've forgot. It's a great resource after all :)
Thank you for writing. nice sharing
http://da-crystal.net/GCMS/blog/checkboxlist-in-qt/
If your next episode would also cover how to replace an existing install of authlogic, that would be great. I've been looking to replace it for awhile now. Also, one feature I find particularly useful in these tools is the ability to impersonate a user so if that exists, it would be nice to hear of too.
Does Devise support a way to do "who is online" functionality? How could this be done?
Hi,
just to let you know that I've build a new syntax highlighting engine in Ruby. It's called Prism and you'll find it here: http://github.com/kib2/Prism.
I've also made a little pastebin with it : http://prism-pastebin.heroku.com/.
The sample you gave renders the following: http://prism-pastebin.heroku.com/13
Please report me any bug/problem, see you.