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
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 %>
need to set up your account, dude
#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 %>
<%= link_to “edit your account options”, :action =>
“edit_options”%>
<% end %>
There’s lots of ways to do this, to be honest, but hopefully this will
get you started