Displaying 20 results from an estimated 80000 matches similar to: "Nested resources routes"
2008 Jul 11
1
Using custom routes to handle new nested resources
I have a couple of resources, one nested in the other, such that my
resource spec in routes.rb is:
map.resources :parents, :has_many => :children
This will generate a route for a new child that assumes that the parent
has already been saved, something like:
/parents/:parent_id/children/new
But what if I want a route that handles the case where the parent
resource is also new, and thus
2009 Oct 23
4
error: nested-routes with nested-model having foreign keys
Hi,
I have this Test, User and Project models where every test belongs_to
a project and project has_many tests.
Test also belongs_to User as ''owner''.
Then i followed railcast#139 to create nested route as -
map.resources :projects, :has_many => :tests
But somehow i get this error when url is ''http://127.0.0.1:3000/
projects/1/tests'' in
2008 Jan 27
4
(REST) Nested routes
Hello, I''m in troubles with nested routes. I have three models: Team,
Tournament and TeamTournaments
class Team < ActiveRecord::Base
has_many :tournaments, :through => :team_tournaments
has_many :team_tournaments
class TeamTournament < ActiveRecord::Base
belongs_to :team, :foreign_key => ''team_id''
belongs_to :tournament, :class_name =>
2009 Mar 08
2
RESTful nested resources and polymorphism?
With ref to my previous post: http://www.ruby-forum.com/topic/180356
I am now able to access items from topics controller. However, now I
need to add sub-item e.g.: An item itself could have many sub-items. So
my items model is like:
class Item < ActiveRecord::Base
validates_uniqueness_of :title, :scope => [:topic_id]
validates_presence_of :topic_id, :title, :owner, :position
2007 Nov 30
2
Nested resources and _path methods
Hi guys,
I was thinking aboiut this for a while:
If I have nested resource routes, for example /building/1/floor/2/
room/
3 (building has_many floors and so on), I have to call the room_path
method like this:
room_path @room.floor.building, @room.floor, @room
IsnĀ“t there a better way to handle nested routes with foreign keys, or
can I have this method overwritten somewhere?
Greets
Jonas
2013 Feb 26
0
Rendering nested resources
Hello,
I have following models:
States has_many Cities
Cities has_many Streets
Streets has_many Houses
Houses has_many People
In the routes.rb I have all these set as nested resources so I can view all
the Cities of specific State as /states/1/cities, all the Streets of given
City as /cities/15/streets, all the Streets of specific State as
/states/27/streets, etc.
Now in the houses#show
2007 Dec 11
4
Lost in translation - Rails 2.0 Nested Resources, Custom Actions
The shift to the :has_many and :has_one options when defining nested
resource routes has me perplexed. The block format allows me to define
custom REST actions like publish in the example below:
map.resources :users do |user|
user.resources :articles, :member => { :publish => :put }
end
It also allows for multiple levels of nesting if necessary.
What I''d really like to
2008 Mar 12
2
nested routes with a 2-way has_many using join table?
I have two classes, InstructionalObject and Assets. They both have_many
of the other, implemented through a join table (so it''s like a habtm
without the habtm).
For the next version of our app, we''re refactoring to RESTful, and i''m
having trouble with my nested resources/routes. I tried this, in
routes.rb:
map.resources :assets do |assets|
assets.resources
2008 Mar 07
4
n-levels of nested resources in REST?
Hi,
I find it would be very convenient to nest resources in two levels, so
a member is only sensible as a part of a club, and a fee pament is
only sensible in the context of a club and a member.
Is it possible to nest nested resources? How would the syntax be?
I have tried just nesting the assignment in routes.rb, but failed to
get it right
What do ou think? Is it possible?
/Fredrik
--
2007 Aug 31
2
How to spec routes for a resource nested in multiples resources?
Hi,
I got the resource "Llamadas" nested in:
- Operadores
- Productos
- Centros
Here is part of my routes http://pastie.caboo.se/92767
I want to spec that the routes for Llamadas, I tried several approachs:
- route_for(:controller => "llamadas", :action => "exitosas",
:operador_id => 1).should == "/operador/1/llamadas;exitosas"
-
2007 Jun 19
3
Nil object for nested resource
Hi all,
I have 2 models with a standard 1 to many relationship. I''m also using
REST on the two models and have added the appropriate code to the
routes.rb file.
scorecard.rb:
class Scorecard < ActiveRecord::Base
has_many :attributes
end
attribute.rb:
class Attribute < ActiveRecord::Base
belongs_to :scorecard
end
routes.rb:
map.resources :scorecards do |scorecard|
2007 Jul 28
0
Nested RESTful Routes and creating a object from XML
I am trying to create a new model from XML that contains has a has_many
relationship. Is this possible without having to write code to parse
the XML or to doing multiple POSTS? I can do a post with XML that
doesn''t contain any of the has_many elements and it works fine. It is
when I add the items from the has_many relationship that I get a bunch
of errors.
Here are the examples I am
2007 Sep 04
1
Routing error with nested resources
Hi -- I have a routes.rb file with the following in it:
<CODE>
map.resource :admin do |admin|
admin.resources :users
admin.resources :clients do |client|
client.resources :client_properties
end
admin.resources :areas
admin.resources :properties
end
</CODE>
My problem is when I try to access the show or edit actions of the
client_properties resource.
The
2011 Nov 10
2
Rails nested Routing
Hi there!
I experienced an issue with routing.
Basically, I''m trying to follow step-by-step the Rails'' official guides
process for what concerns the nested routing.
So, I have Newspapers that has_many :ads , and :ads belongs to
:newspaper .
What I did was simply trying to obtain an URL like this:
http://localhost/newspapers/1/ads/1
but when I set routes.rb in this way:
2008 Jan 04
2
Nested Routes + Facebook Resources
Does anyone have nested routes working with the facebook_resources
method?
My routes.rb has:
map.facebook_resources :users do |users|
users.facebook_resources :images
users.facebook_resources :connections
end
but user_connections_url won''t generate.
"rake routes" gives me:
new_user POST /users/new
{:action=>"new",
2008 Jul 12
3
calculations on nested resources
Hi,
I can''t seem to find a solution to the folowing problem.
I have 3 resources that are all bound to eachother like this:
class Item < ActiveRecord::Base
belongs_to :item_category
// has a date and amount attr
end
class ItemCategory < ActiveRecord::Base
has_many :items
has_many :item_tops
// groups the items in categories
end
class ItemTop < ActiveRecord::Base
2011 Aug 22
0
Paperclip nested resources problem
My models:
class Country < ActiveRecord::Base
has_many :regions
has_many :assets, :dependent => :destroy
accepts_nested_attributes_for :assets
end
class Region < ActiveRecord::Base
belongs_to :country
has_many :appartments
has_many :assets, :dependent => :destroy
accepts_nested_attributes_for :assets
end
class Asset < ActiveRecord::Base
belongs_to :region
2010 Mar 08
0
Nested Resources + Namespace + Friendly URL
Hi, all
In my rails app I have a controller called Dashboard::MenusController
with a namespace dashboard.
I have a model Company too, where its has_many :menus
So, I have the code above in my route.rb
map.namespace (:dashboard) do |dashboard|
dashboard.resources :companies,
:has_many => :menus
end
With this route I can create a new menu by: dashboard/companies/1/
2006 Sep 30
1
possible bug: edge rails, nested resources and images
Im trying to show images in my restful application and have finally
found what appears to be the source of the problem.
When i have the products resource nested in categories as showen below
in the first routes file i can see the categories index (/categories).
When i add the images to the products resource map as shown in routes 2
i get the error:
image_url failed to generate from
2007 Aug 16
1
Nested REST resource routes without controller name
I am curious if the following URL pattern is appropriate to use with
REST and map.resources:
Let''s say I want to build a website with information about cars. I
decide that there will be a page to view/manage cars by model. The
route for this is easily created:
map.resources :cars
The URLs look great. But now I want to introduce the ability to
specify cars by year. I can do this by