I need to create an object from just a button.
I do not pass anything to the method, I just call it through the button.
All the data I need to access the controller action I'm using.
But I can not insert into the database, because of Strong Parameters.
I've tried so much solution that I do not even know what I'm doing anymore. :
Here I try to create a new token the data I generated in the action
@token = Token.new(duration: duration, token: token, check: false, user_id: current_user.id)
This is the part of the strong parameters
def token_params
params.require(:token).permit(:duration, :token, :check, :user_id, :gym_id)
end
And when I check the parameters I passed to the action. Ex: {"utf8" => "✓" ....} The "token" hash does not come together, maybe this is obvious because I'm not sending anything other than the commit button.