Want to notify user if his prefs are not set up

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

nephish wrote:

the options table.

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

cool, thanks much for the help
sk

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs