how do i assign constants on sqlite using ruby? -


I am new on rail and I have a problem, I want to add entries with value 0 on my DB, but only Form values ​​are included.

_form.html.erb

  & lt; Div class = "field" & gt; & Lt;% = f.label: name% & gt; & Lt; Br> & Lt;% = f.text_field: name% & gt; & Lt; / Div & gt; & Lt; Div class = "field" & gt; & Lt;% = f.label: league% & gt; & Lt; Br> & Lt;% = f.number_field: League% & gt; & Lt; / Div & gt; & Lt; Div class = "field" & gt; & Lt;% = f.label: Color% & gt; & Lt; Br> & Lt;% = f.text_field: Color% & gt; & Lt; / Div & gt; & Lt; Div class = "verb" & gt; & Lt;% = f.submit% & gt; & Lt; / Div & gt; & Lt;% end% & gt;  

Controller

def make @ tam = team.New (team_most) enddef team_param parameter.quare (: team). Passit (: name, League, color, points: 0, owner: current_user.id) end

CMD output:

So my question is: How do I add a static / current user id to my SQLite database?

In the pre-order

I handle the current_user's settings in the controller.

Create attribute in the controller def = Team_params.merge (Owner: Current_User) @tem = Team.Creats (Attributes) ... and Private Diet Team. Ultimate Parameters.Require (Team) .Permit (: name, league, color) and

Where to ensure that some features have been set (or default) should be part of the model The methods are: defaults in the database, gem or before this simple_valadation callback:

  #p The team's model: Samanyikrit_adikar private def normalize_attributes self.points || = 0 end  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -