Good Day, i''m having a trouble with the routes in Ruby on Rails 4
Error:
undefined method `routes_path''
View:
<h1>Load data</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for @route, :html => { :multipart => true } do %>
<%= hidden_field_tag ''current_user'', @current_user
%>
<%= file_field_tag :file %>
<%= submit_tag "Import", style: ''margin-top:
-10px'', class: "btn
btn-primary" %>
<% end %>
</div>
</div>
Controller:
def new
@route = current_user.build_route
end
def create
nil_flag = Route.import(params[:file], current_user)
if nil_flag == 1
flash[:success] = "Data created."
redirect_to route_path(current_user)
else
flash[:error] = "Error"
redirect_to load_data_path
end
end
Model:
def self.import(file, current_user)
@user = current_user
@route = @user.build_route
@nil_flag = 0
File.open(file.path, ''r'') do |f|
.
.
.
#etc
end
Routes
match ''/load_data'', to: ''routes#new'', via:
''get''
Views, controller and model are named "Route"
Is a problem with the route in the view or something else? Thank you
--
Posted via http://www.ruby-forum.com/.
--
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
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/eff044ee6f84f04a3fcb8b5054266d39%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.
Routes match ''/load_data'', to: ''routes#new'', via: ''get'' I think the problem in your routes file. Remove this line "*match ''/load_data'', to: ''routes#new'', via: ''get*'' " and add this line- *"resources :routes" *. On Wed, Oct 23, 2013 at 1:33 AM, Jose Urquidi <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Good Day, i''m having a trouble with the routes in Ruby on Rails 4 > > > Error: > > undefined method `routes_path'' > > > View: > > <h1>Load data</h1> > <div class="row"> > <div class="span6 offset3"> > <%= form_for @route, :html => { :multipart => true } do %> > <%= hidden_field_tag ''current_user'', @current_user %> > <%= file_field_tag :file %> > <%= submit_tag "Import", style: ''margin-top: -10px'', class: "btn > btn-primary" %> > <% end %> > </div> > </div> > > > Controller: > > def new > @route = current_user.build_route > end > > def create > nil_flag = Route.import(params[:file], current_user) > if nil_flag == 1 > flash[:success] = "Data created." > redirect_to route_path(current_user) > else > flash[:error] = "Error" > redirect_to load_data_path > end > end > > Model: > > def self.import(file, current_user) > @user = current_user > @route = @user.build_route > @nil_flag = 0 > > File.open(file.path, ''r'') do |f| > . > . > . > #etc > end > > > > Routes > > match ''/load_data'', to: ''routes#new'', via: ''get'' > > > Views, controller and model are named "Route" > > Is a problem with the route in the view or something else? Thank you > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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 rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/eff044ee6f84f04a3fcb8b5054266d39%40ruby-forum.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- ---------------------------------------------------------------------------------------------------- Thank You. Best Wishes, BalaRaju Vankala, 8886565300. -- 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 rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAGQ0aif-ARaJDs8Yi_JMxYyDcCvNGF_%2B-M935y9CfY6RTaxF7Q%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Just as a first impression, without looking into it in detail - you may
have trouble using routes as a class name, it''s already a class name
under
ActionDispatch.
However, I think your problem is actually your route:
match ''/load_data'', to: ''routes#new'', via:
''get''
This isn''t a resource route, it won''t generate the kind of
functionality
that allows you to use the form tag syntax <%= form_for @route...
Either define routes as a resource:
resources :routes
Or define a url in your form:
<%= form_for @route, :url => some_url, :html => { :multipart => true
} do
%>
On Wed, Oct 23, 2013 at 3:22 PM, BalaRaju Vankala
<foreverbala4u-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:
> Routes
>
> match ''/load_data'', to: ''routes#new'',
via: ''get''
>
> I think the problem in your routes file.
> Remove this line "*match ''/load_data'', to:
''routes#new'', via: ''get*'' "
> and add this line- *"resources :routes" *.
>
>
>
> On Wed, Oct 23, 2013 at 1:33 AM, Jose Urquidi
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:
>
>> Good Day, i''m having a trouble with the routes in Ruby on
Rails 4
>>
>>
>> Error:
>>
>> undefined method `routes_path''
>>
>>
>> View:
>>
>> <h1>Load data</h1>
>> <div class="row">
>> <div class="span6 offset3">
>> <%= form_for @route, :html => { :multipart => true } do
%>
>> <%= hidden_field_tag ''current_user'',
@current_user %>
>> <%= file_field_tag :file %>
>> <%= submit_tag "Import", style:
''margin-top: -10px'', class: "btn
>> btn-primary" %>
>> <% end %>
>> </div>
>> </div>
>>
>>
>> Controller:
>>
>> def new
>> @route = current_user.build_route
>> end
>>
>> def create
>> nil_flag = Route.import(params[:file], current_user)
>> if nil_flag == 1
>> flash[:success] = "Data created."
>> redirect_to route_path(current_user)
>> else
>> flash[:error] = "Error"
>> redirect_to load_data_path
>> end
>> end
>>
>> Model:
>>
>> def self.import(file, current_user)
>> @user = current_user
>> @route = @user.build_route
>> @nil_flag = 0
>>
>> File.open(file.path, ''r'') do |f|
>> .
>> .
>> .
>> #etc
>> end
>>
>>
>>
>> Routes
>>
>> match ''/load_data'', to:
''routes#new'', via: ''get''
>>
>>
>> Views, controller and model are named "Route"
>>
>> Is a problem with the route in the view or something else? Thank you
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> --
>> 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
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To view this discussion on the web visit
>>
https://groups.google.com/d/msgid/rubyonrails-talk/eff044ee6f84f04a3fcb8b5054266d39%40ruby-forum.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
>
>
----------------------------------------------------------------------------------------------------
> Thank You.
>
> Best Wishes,
>
> BalaRaju Vankala,
> 8886565300.
>
>
> --
> 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
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/rubyonrails-talk/CAGQ0aif-ARaJDs8Yi_JMxYyDcCvNGF_%2B-M935y9CfY6RTaxF7Q%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
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
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/CAJgx-dgfP3KN4BEpfj3g4kGMHWwSb%3DJjXQEEfGR8LpVPxzmoRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.