ruby-on-rails – Create an object with strong parameters in Ruby on Rails


I need to create an object from just a button.

I don't pass anything to the method, I just call it through the button.

All the data I need I have access to in the controller action I'm using.

But I can't insert it in the database, because of Strong Parameters.

I've tried so much solution that I don't even know what I'm doing anymore. :/

Here I try to create a new token with the data I generated in the action

@token = duration, token: token, check: false, user_id:

This is the strong parameters part.

def token_params
      params.require(:token).permit(:duration, :token, :check, :user_id, :gym_id)

And when I check the parameters I passed to the action. Ex.: {"utf8"=>"✓" …. } Hash "token" doesn't come with it, maybe that's obvious since I'm not sending anything besides the button commit.


You really don't need strong params in this case. I believe that just changing new to create will solve your problem in your action .

Scroll to Top