Quantcast

additional params in controller create action

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

additional params in controller create action

fugee ohu
I'm trying to assign additional parameters to create to satisfy validations in the model like so
address="params[:address0] + params[:address1]
@user.address=address
if @user.save
...
In this example there's address0 and address1 in the form but not the schema which has only :address
Should this work?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fa52769d-ae0e-41de-90ef-9acca82edc23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: additional params in controller create action

Colin Law
On 26 April 2017 at 02:04, fugee ohu <[hidden email]> wrote:
> I'm trying to assign additional parameters to create to satisfy validations
> in the model like so
> address="params[:address0] + params[:address1]
> @user.address=address
> if @user.save
> ...
> In this example there's address0 and address1 in the form but not the schema
> which has only :address
> Should this work?

Try it and see. If it does not then debug it to find why.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvw9LU-1zxw_az%3D5uem4BbZPXPyGnQL5vnTR_rnONOr6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: additional params in controller create action

fugee ohu


On Wednesday, April 26, 2017 at 3:25:53 AM UTC-4, Colin Law wrote:
On 26 April 2017 at 02:04, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="_OgxDKlMAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
> I'm trying to assign additional parameters to create to satisfy validations
> in the model like so
> address="params[:address0] + params[:address1]
> @user.address=address
> if @user.save
> ...
> In this example there's address0 and address1 in the form but not the schema
> which has only :address
> Should this work?

Try it and see. If it does not then debug it to find why.

Colin

Same select rolls back and then succeeds after render  in the case of save didn't succeed Other than this I'm clueless

  User Load (28.2ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1
  Artist Load (4.6ms)  SELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1
   (0.9ms)  BEGIN
   (3.7ms)  ROLLBACK
  Rendering user/press_releases/_form.html.erb within layouts/application
  Artist Load (2.6ms)  SELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/344f6bbb-0cff-4539-89d7-dadd0d77e548%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: additional params in controller create action

Colin Law
On 26 April 2017 at 14:02, fugee ohu <[hidden email]> wrote:

>
>
> On Wednesday, April 26, 2017 at 3:25:53 AM UTC-4, Colin Law wrote:
>>
>> On 26 April 2017 at 02:04, fugee ohu <[hidden email]> wrote:
>> > I'm trying to assign additional parameters to create to satisfy
>> > validations
>> > in the model like so
>> > address="params[:address0] + params[:address1]
>> > @user.address=address
>> > if @user.save
>> > ...
>> > In this example there's address0 and address1 in the form but not the
>> > schema
>> > which has only :address
>> > Should this work?
>>
>> Try it and see. If it does not then debug it to find why.
>>
>> Colin
>
>
> Same select rolls back and then succeeds after render  in the case of save
> didn't succeed Other than this I'm clueless
>
>   User Load (28.2ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 2
> ORDER BY `users`.`id` ASC LIMIT 1
>   Artist Load (4.6ms)  SELECT  `artists`.* FROM `artists` WHERE
> `artists`.`id` = 14 LIMIT 1
>    (0.9ms)  BEGIN
>    (3.7ms)  ROLLBACK
>   Rendering user/press_releases/_form.html.erb within layouts/application
>   Artist Load (2.6ms)  SELECT  `artists`.* FROM `artists` WHERE
> `artists`.`id` = 14 LIMIT 1

Did your debugging show that @user.address is setup correctly?

Colin

>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/344f6bbb-0cff-4539-89d7-dadd0d77e548%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuByc4Nfcf%3DYrHv%2BZ3cOL0epfOW4bwNwJM%2BLtP1XwqSSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...