Forum: Ruby on Rails Click in a radiobutton, enable button on solicit.html.erb and save on db

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2e903d3512efa714af85ed919b2ece46?d=identicon&s=25 Elton Santos (Guest)
on 2016-05-12 20:39
(Received via mailing list)
I really dont know how begin, I have a form in my view
(solicit.html.erb)
where do iterate in each elements, each element have a radio button,
input
field and a button for create. When click on button, generate a new
portability with date save this. this is my code

<% if params[:search_func_register].present? %>
>         </thead>
>               <td><%= link_to "Request", new_portability_path %></td>
>             </tr>
>           <% end %>
>         </tbody>
>       </table>
>     <% end %>
> <% end %>



I just create a new portability with this values on form... (id,
new_parcel)

Contract_number is readonly for show what is the authorization that is
doing this portability.

My portabilities_controller is:

 def index
> params[:search_func_register]).includes(:authorizations)
>       @authorizations = Authorization.where(employee_id: @employee)
>       @portability = Portability.new
>     else
>       @authorizations = Authorization.all
>     end
>   end



But all this return this error when click on button Request:

undefined method `model_name' for nil:NilClass


I guess that create a other page for new portability is the solution. My
route is:

resources :portabilities, except: :destroy do
>     collection do
>       get 'solicit'
>     end
>   end


Any idea about this, some tips? See ya!!
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2016-05-12 21:33
(Received via mailing list)
On 12 May 2016 at 19:38, Elton Santos <elton.melo.santos@gmail.com>
wrote:
> I really dont know how begin, I have a form in my view (solicit.html.erb)
> where do iterate in each elements, each element have a radio button, input
> field and a button for create. When click on button, generate a new
> portability with date save this. this is my code
>
>> <% if params[:search_func_register].present? %>
>>   <h4><b>Results</b></h4>
>>     <%= form_tag(@portability, name: 'form', method: :get) do %>

It is always a good idea to copy/paste the complete error message for
us to see, and in particular tell us which line of code it refers to.
I will try to guess, however.  The error means that something is nil
that should not be.  Is the error on the form_tag line?  If so it
probably means that @portability is nil.

Colin
This topic is locked and can not be replied to.