hey all, i have a bunch of users each user has_one :user_option user options contains info about how to handle the users data , preferences and such what i would like to do in the summary page ( page after logging in ) is display a link with a message if the user has not created his row in the options table. would i use something like: if user.option.nil? @flash[:message] = ''need to set up your account, dude'' render_partial blah blah blah else render_partial some link like ''edit my options'' or whatever thanks sk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
nephish wrote:> hey all, > > i have a bunch of users > each user has_one :user_option > > user options contains info about how to handle the users data , > preferences and such > > what i would like to do in the summary page ( page after logging in ) > is display a link with a message if the user has not created his row in > the options table. > > would i use something like: > if user.option.nil? > @flash[:message] = ''need to set up your account, dude'' > render_partial blah blah blah > else > render_partial some link like ''edit my options'' or whatever > > thanks > sk > > > > > >Sort of, though you''re mixing up the controller and view a little bit. Although it''s not a good idea to put much code in the view I''d probably just do something like this in the view: <% if user.option %> <p><strong>need to set up your account, dude</strong></p> #nil will evaluate as false so don''t need explicit test for it <%= render :partial => "setup_account" %> # assuming this is some sort of setup form <% else %> <p><%= link_to "edit your account options", :action => "edit_options"%></p> <% end %> There''s lots of ways to do this, to be honest, but hopefully this will get you started --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
cool, thanks much for the help sk On 11/24/06, Chris T <ctmailinglists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > nephish wrote: > > hey all, > > > > i have a bunch of users > > each user has_one :user_option > > > > user options contains info about how to handle the users data , > > preferences and such > > > > what i would like to do in the summary page ( page after logging in ) > > is display a link with a message if the user has not created his row in > > the options table. > > > > would i use something like: > > if user.option.nil? > > @flash[:message] = ''need to set up your account, dude'' > > render_partial blah blah blah > > else > > render_partial some link like ''edit my options'' or whatever > > > > thanks > > sk > > > > > > > > > > > > Sort of, though you''re mixing up the controller and view a little bit. > > Although it''s not a good idea to put much code in the view I''d probably > just do something like this in the view: > <% if user.option %> > <p><strong>need to set up your account, dude</strong></p> #nil will > evaluate as false so don''t need explicit test for it > <%= render :partial => "setup_account" %> # assuming this is some > sort of setup form > <% else %> > <p><%= link_to "edit your account options", :action => > "edit_options"%></p> > <% end %> > > There''s lots of ways to do this, to be honest, but hopefully this will > get you started > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---