M
M
micmakarov2012-03-20 22:56:20
Ruby on Rails
micmakarov, 2012-03-20 22:56:20

Id of the current user from the controller (devise)?

I create a gain entry, I want gain.user_id to be equal to the current user. Provided that Devise installed
how to do it? "current_user" helper in controller doesn't work(
@gain = @task.gains.create(params[:gain])

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmitrynesterov, 2012-03-21
@dmitrynesterov

params_gains = params[:gain].merge(:user => current_user)
@gain = @task.gains.create(params_gains)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question