Friday, March 12, 2010

Setting facebook user_id

Most of the forms in rails are tied to a resource. Submitting a form results in creating an
object of the resource and a record in the table of the model representing that resource.
Submitting a new form is tied to a new method in the controller associated with that resource.

When working in facebook we need to associate a user_id when a from is submitted. This is how the user_id is set in create method.
def create
current_user.honors.create(params[:honor]) - where honor is the resource
redirect_to honors_path
end

No comments:

Post a Comment