Url helpers don't work in AR models full stop, nevermind in callbacks. This is by design- your model layer should be able to operate outside of the context of a web server.
Up vote 0 down vote favorite share g+ share fb share tw.
The url_helpers do not seem to be working in my User model during an after_create callback. Here is the error... NameError in Devise/registrationsController#create undefined local variable or method `controller' for... class User true, :email_requests => true) self. Is_travel_planner?
Buyer = true : buyer = false ##### THIS IS WHERE IT BREAKS########################## step_1 = link_to('Setup your personal profile', edit_user_path(self)) step_2 = link_to('Setup/update your company profile', '/organizations/new? User_id=' + self.id. To_s) if buyer == true step_3 = link_to "Find potential suppliers by name, location, person, and more!
", "/organizations/new? User_id=" + self.id. To_s else step_3 = link_to "Make Connections with qualified buyers!
", "/organizations/new? User_id=" + self.id. To_s end name = self.
Name_first type = 'suppliers' content = "Welcome #{name}, The iTourSmart community is built upon a powerful web-based tool that allows you to find and connect with #{type} like never before. Building your business with iTourSmart is as easy as 1-2-3! Step 1: Setup your personal profile Step 2: #{step_2} Step 3: #{step_3} =Of course, you can simply close this window and look around right now.
This message is stored in your message center and can be accessed at any time. " new_note = self.notes. Create(:is_fancybox_autoload => true, :is_sysmessage => true, :subject => "Setup your brand", :body => content) else self.roles.
Create(:user_id => self. Id, :organization_id => self. Temp_org_id) self.
Update_attributes(:temp_org_id => nil, :email_messages => true, :email_requests => true) end end end Any help is greatly appreciated! Ruby-on-rails devise link|improve this question edited Jan 20 '11 at 20:25 asked Jan 20 '11 at 20:13Patrick Connor329111 100% accept rate.
Url helpers don't work in AR models full stop, nevermind in callbacks. This is by design- your model layer should be able to operate outside of the context of a web server. You can fudge the issue by including bits of the web stack in to the model and there are several questions on SO that will tell you how.. The first one in the related list for this question is: Can Rails Routing Helpers (i.e.
Mymodel_path(model)) be Used in Models?
Thanks. After more research, I think the issue stems from the use of Devise as well. I have added more info to my question.
– Patrick Connor Jan 20 '11 at 20:27 I think you're going about this backasswards. Rather than creating a big ugly string for a note in your model, when the user comes to look at their notes, create it there with all the goodies of templates, url helpers and copious model objects at your disposal. – noodl Jan 20 '11 at 20:36 Thanks for the insight.
That makes a lot of sense. Is the "best" way to set a flag on the User record to track if it is the first login? – Patrick Connor Jan 20 '11 at 20:43 Yes, absolutely.
Store whatever state is necessary to track the user's progress through your registration process but keep the view stuff in the view layer. If you want to get clever with it you could add a state machine to your model so you have guarded transitions from one state to the next and so forth. – noodl Jan 20 '11 at 20:52.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.