vendredi 4 mai 2018

Get value out of static rails select_tag

I have just started out programming with ruby on rails. I really like it, but sometimes it's really complicated. What I am trying to do is to get the selected value out of the select_tag and pass it to the Model where I will multiply the value to another one (that comes from an from_for textfield). The problem is I wasn't able to figure out how to get the value from the View to the Controller and then to the Model.

Here is my code:

View:

<%= label_tag 'Remind' %> <br />

Controller:

f create
add = Item.new(item_params)


if add.save
  flash[:notice] = ''
  redirect_to items_path
else
  redirect_to new_item_path
  flash[:error] = ''
end

end

Model:

def convert_to_d
convert = self.remind * self.v_convertor
self.assign_attributes(remind: convert)

end

Thank you in advance




Aucun commentaire:

Enregistrer un commentaire