Cisco Ri wrote:
>
> Thanks for letting me know. In links/new, how would I go about
> including the current user_id? The only way I know of would be a hidden
> form element, and I would like to keep it all server side.
Restful Authentication has the notion of current_user, does it not?
Check in the authenticated_system.rb file in lib for a peek at some
methods you have available to you.
There's no need to know the current_user's id in the links controller's
new action, that just needs to manufacture an @link for the new.html.erb
form.
You will need it for the create action in the links controller though.
Something like:
def create
@link = Link.new(params[:link])
if logged_in?
@link.user_id = current_user.id
if @link.save
redirect_to(@link)
else
render :action => 'new'
end
else
# redirect to your login page?
# I'd actually defend this method with a before_filter, and get
# rid of this if logged_in? stuff
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---