Lorenzo Brito Morales
2011-Feb-08 16:14 UTC
layout "restaurant" stop working link to deltemethod
Hi, if i want to specify what layout has to use the view, the link to delete method stop workind and take to show view. i class RestaurantsController < ApplicationController # GET /restaurants # GET /restaurants.xml layout "restaurants" def index @restaurants = Restaurant.all my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" } puts JSON.pretty_generate(my_json) respond_to do |format| # format.html # index.html.erb # format.xml { render :xml => @restaurants } format.json {render :json => @restaurants} end end # GET /restaurants/1 # GET /restaurants/1.xml def show puts params[0] @restaurant = Restaurant.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @restaurant } format.json {render :json => @restaurant.comidas} end end # GET /restaurants/new # GET /restaurants/new.xml def new @restaurant = Restaurant.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @restaurant } end end # GET /restaurants/1/edit def edit @restaurant = Restaurant.find(params[:id]) end # POST /restaurants # POST /restaurants.xml def create @restaurant = Restaurant.new(params[:restaurant]) respond_to do |format| if @restaurant.save format.html { redirect_to(@restaurant, :notice => ''Restaurant was successfully created.'') } format.xml { render :xml => @restaurant, :status => :created, :location => @restaurant } else format.html { render :action => "new" } format.xml { render :xml => @restaurant.errors, :status => :unprocessable_entity } end end end # PUT /restaurants/1 # PUT /restaurants/1.xml def update @restaurant = Restaurant.find(params[:id]) respond_to do |format| if @restaurant.update_attributes(params[:restaurant]) format.html { redirect_to(@restaurant, :notice => ''Restaurant was successfully updated.'') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @restaurant.errors, :status => :unprocessable_entity } end end end # DELETE /restaurants/1 # DELETE /restaurants/1.xml def destroy @restaurant = Restaurant.find(params[:id]) @restaurant.destroy respond_to do |format| format.html { redirect_to(restaurants_url) } format.xml { head :ok } end end end that are the controller these is the view <h1>Listing restaurants</h1> <table> <tr> <th></th> <th></th> <th></th> </tr> <% @restaurants.each do |restaurant| %> <tr> <td> <%= restaurant.nombre %> </td> <td><%= link_to ''Show'', restaurant %></td> <td><%= link_to ''Edit'', edit_restaurant_path(restaurant) %></td> <td><%= link_to ''Destroy'',restaurant, :confirm => ''Are you sure?'', :method => :delete %></td> //these take to <td><%= link_to ''Show'', restaurant %></td> </tr> <% end %> </table> <br /> <%= link_to ''New Restaurant'', new_restaurant_path %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Gintautas Šimkus
2011-Feb-08 16:28 UTC
Re: layout "restaurant" stop working link to deltemethod
Try restaurant_path for delete. 2011/2/8 Lorenzo Brito Morales <lorenzo.brito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Hi, if i want to specify what layout has to use the view, the link to > delete method stop workind > and take to show view. i > > class RestaurantsController < ApplicationController > # GET /restaurants > # GET /restaurants.xml > layout "restaurants" > def index > @restaurants = Restaurant.all > my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" } > puts JSON.pretty_generate(my_json) > respond_to do |format| > # > format.html # index.html.erb > # > format.xml { render :xml => @restaurants } > format.json {render :json => @restaurants} > end > end > > # GET /restaurants/1 > # GET /restaurants/1.xml > def show > puts params[0] > @restaurant = Restaurant.find(params[:id]) > > respond_to do |format| > format.html # show.html.erb > format.xml { render :xml => @restaurant } > format.json {render :json => @restaurant.comidas} > end > end > > # GET /restaurants/new > # GET /restaurants/new.xml > def new > @restaurant = Restaurant.new > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @restaurant } > end > end > > # GET /restaurants/1/edit > def edit > @restaurant = Restaurant.find(params[:id]) > end > > # POST /restaurants > # POST /restaurants.xml > def create > @restaurant = Restaurant.new(params[:restaurant]) > > respond_to do |format| > if @restaurant.save > format.html { redirect_to(@restaurant, :notice => ''Restaurant > was successfully created.'') } > format.xml { render :xml => @restaurant, :status => :created, > :location => @restaurant } > else > format.html { render :action => "new" } > format.xml { render :xml => @restaurant.errors, :status => > :unprocessable_entity } > end > end > end > > # PUT /restaurants/1 > # PUT /restaurants/1.xml > def update > @restaurant = Restaurant.find(params[:id]) > > respond_to do |format| > if @restaurant.update_attributes(params[:restaurant]) > format.html { redirect_to(@restaurant, :notice => ''Restaurant > was successfully updated.'') } > format.xml { head :ok } > else > format.html { render :action => "edit" } > format.xml { render :xml => @restaurant.errors, :status => > :unprocessable_entity } > end > end > end > > # DELETE /restaurants/1 > # DELETE /restaurants/1.xml > def destroy > @restaurant = Restaurant.find(params[:id]) > @restaurant.destroy > > respond_to do |format| > format.html { redirect_to(restaurants_url) } > format.xml { head :ok } > end > end > end > that are the controller > these is the view > > <h1>Listing restaurants</h1> > > <table> > <tr> > <th></th> > <th></th> > <th></th> > </tr> > > <% @restaurants.each do |restaurant| %> > <tr> > <td> <%= restaurant.nombre %> </td> > <td><%= link_to ''Show'', restaurant %></td> > <td><%= link_to ''Edit'', edit_restaurant_path(restaurant) %></td> > <td><%= link_to ''Destroy'',restaurant, :confirm => ''Are you sure?'', > :method => :delete %></td> //these take to <td><%= link_to ''Show'', > restaurant %></td> > </tr> > <% end %> > </table> > > <br /> > > <%= link_to ''New Restaurant'', new_restaurant_path %> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Lorenzo Brito Morales
2011-Feb-10 22:13 UTC
Re: layout "restaurant" stop working link to deltemethod
it was a problem with a <script> in the layout i put a link to jquery in other part of the page instead of head tag. thanks anyway On Tue, Feb 8, 2011 at 10:28 AM, Gintautas Šimkus <dihitales-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try restaurant_path for delete. > > 2011/2/8 Lorenzo Brito Morales <lorenzo.brito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> >> Hi, if i want to specify what layout has to use the view, the link to >> delete method stop workind >> and take to show view. i >> >> class RestaurantsController < ApplicationController >> # GET /restaurants >> # GET /restaurants.xml >> layout "restaurants" >> def index >> @restaurants = Restaurant.all >> my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" } >> puts JSON.pretty_generate(my_json) >> respond_to do |format| >> # >> format.html # index.html.erb >> # >> format.xml { render :xml => @restaurants } >> format.json {render :json => @restaurants} >> end >> end >> >> # GET /restaurants/1 >> # GET /restaurants/1.xml >> def show >> puts params[0] >> @restaurant = Restaurant.find(params[:id]) >> >> respond_to do |format| >> format.html # show.html.erb >> format.xml { render :xml => @restaurant } >> format.json {render :json => @restaurant.comidas} >> end >> end >> >> # GET /restaurants/new >> # GET /restaurants/new.xml >> def new >> @restaurant = Restaurant.new >> >> respond_to do |format| >> format.html # new.html.erb >> format.xml { render :xml => @restaurant } >> end >> end >> >> # GET /restaurants/1/edit >> def edit >> @restaurant = Restaurant.find(params[:id]) >> end >> >> # POST /restaurants >> # POST /restaurants.xml >> def create >> @restaurant = Restaurant.new(params[:restaurant]) >> >> respond_to do |format| >> if @restaurant.save >> format.html { redirect_to(@restaurant, :notice => ''Restaurant >> was successfully created.'') } >> format.xml { render :xml => @restaurant, :status => :created, >> :location => @restaurant } >> else >> format.html { render :action => "new" } >> format.xml { render :xml => @restaurant.errors, :status => >> :unprocessable_entity } >> end >> end >> end >> >> # PUT /restaurants/1 >> # PUT /restaurants/1.xml >> def update >> @restaurant = Restaurant.find(params[:id]) >> >> respond_to do |format| >> if @restaurant.update_attributes(params[:restaurant]) >> format.html { redirect_to(@restaurant, :notice => ''Restaurant >> was successfully updated.'') } >> format.xml { head :ok } >> else >> format.html { render :action => "edit" } >> format.xml { render :xml => @restaurant.errors, :status => >> :unprocessable_entity } >> end >> end >> end >> >> # DELETE /restaurants/1 >> # DELETE /restaurants/1.xml >> def destroy >> @restaurant = Restaurant.find(params[:id]) >> -X/bbetz7PneWho+s7ZRLrwS+D6j9UgRo@public.gmane.org >> >> respond_to do |format| >> format.html { redirect_to(restaurants_url) } >> format.xml { head :ok } >> end >> end >> end >> that are the controller >> these is the view >> >> <h1>Listing restaurants</h1> >> >> <table> >> <tr> >> <th></th> >> <th></th> >> <th></th> >> </tr> >> >> <% @restaurants.each do |restaurant| %> >> <tr> >> <td> <%= restaurant.nombre %> </td> >> <td><%= link_to ''Show'', restaurant %></td> >> <td><%= link_to ''Edit'', edit_restaurant_path(restaurant) %></td> >> <td><%= link_to ''Destroy'',restaurant, :confirm => ''Are you sure?'', >> :method => :delete %></td> //these take to <td><%= link_to ''Show'', >> restaurant %></td> >> </tr> >> <% end %> >> </table> >> >> <br /> >> >> <%= link_to ''New Restaurant'', new_restaurant_path %> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.