Hello ,
add the bold line of code into ur controller (forum) and check.. It
works....
def forum
if request.post? and params[:blog]
@blog = Blog.new(params[:blog])
*@blog.user_id = session[:user_id]*
if @blog.save
flash[:notice]="posted"
else
flash[:error]="not posted"
end
end
end
Thanks & Regards,
Saideep Annadatha
On Sat, Nov 8, 2008 at 2:57 PM, Ishara Gunathilake <
jaimgunathilake-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> i have a session variable called user_id,i want to store
> it in a table named blogs
> t.column :user_id,
> t.column :title,
> t.column :body,
>
> i have a form which includes title and
> body,i can save them in the table, here is my code
>
> def forum
> if request.post? and params[:blog]
> @blog = Blog.new(params[:blog])
> if @blog.save
> flash[:notice]="posted"
> else
> flash[:error]="not posted"
> end
> end
> end
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---