nested-resources

form for nested resource

泄露秘密 提交于 2019-12-12 08:45:12
问题 I have gone through tons of the form_for nested resource questions and can't get any of the solutions to work for me. I figured its time to ask a personalized question. I have two models, jobs and questions, jobs has_many questions and questions belong_to jobs. I used scaffolding to create the controllers and models then nested the resources in the routes.rb. root :to => "pages#home" resources :jobs do resources :questions end get "pages/home" get "pages/about" get "pages/contact" class Job <

Spring Data Rest - Include nested resource in _embedded

五迷三道 提交于 2019-12-12 07:20:52
问题 I'm developing a Spring Boot Application for a shopping list. For this I use Spring Data Rest to export my entities through a REST API. My Architecture looks like this I have a ShoppingItem : public class ShoppingItem { @Id @GeneratedValue private Long id; @ManyToOne @JoinColumn(name = "articleId", nullable = false) private Article article; private Integer number; private boolean bought; public ShoppingItem(){ this.article = null; this.number = 0; this.bought = false; } } This shopping item

Rails 3.2 - Nested Resource Passing ID

霸气de小男生 提交于 2019-12-12 02:52:07
问题 Okay so my associations are: Outlet -> has_many :monitorings Monitoring -> belongs_to :outlet My Routes: resources :outlets do resources :monitorings end View: <%= link_to new_outlet_monitoring_path(@outlet) %> When I click the link, the logs show that the outlet_id is passed as a parameter to the new page correctly. But when saving the monitoring record, the outlet_id becomes nil. Any help? UPDATE: # views/monitorings/_form.html.erb <%= form_for(@monitoring) do |f| %> <h2>Type of Monitoring<

Railstutorial.org book, changing to nested routes

和自甴很熟 提交于 2019-12-12 01:33:46
问题 Hi I've been following along in the Rails Tutorial book, creating users and posts and a feed to show the posts. However, the author never used nested resources, which seem to be very important in rails and I would like to discover how to use them myself. However, when I nest the post resource according to Ruby on rails guides, it subsequently breaks all my forms and paths. Instead of starting over I would like change over to nested resources and in the process learn exactly what the

Rails: Nested resources

天大地大妈咪最大 提交于 2019-12-11 20:17:53
问题 The following path throws up an error: = link_to 'Subscribers', user_subscribers_path(current_user) undefined method `user_subscribers_path' for <#:0x007f9b240b3148> I am not sure why. I have defined my routes as follows: resources :users, :only => [:show, :index], :has_many => :subscribers, :shallow => true Thanks! EDIT rake routes does not show anything particularly useful. The only two lines with subscribers are: users GET /users(.:format) users#index {:has_many=>:subscribers} user GET

Getting the parent resource from the URL

北慕城南 提交于 2019-12-11 06:37:07
问题 I've got two objects (@stacks and @stories) with has_many relationships (through @anthologies). Stories can be viewed individually (/stories/1/) or as a collection in a Stack (/stacks/1/stories/1/). map.resources :stories map.resources :anthologies map.resources :stacks, :has_many => :stories do |stack| stack.resources :stories end I've got this basic frame working I'm trying to identify the when a story is being rendered as part of a stack so that I can build some navigation between stories.

I can't create model objects using accepts_nested_attributes_for. It won't create the nested object

故事扮演 提交于 2019-12-10 20:37:25
问题 My model structure looks like this: Board has_many Topics. Topic has_many Posts. app/models/board.rb class Board < ActiveRecord::Base has_many :topics end app/models/topic.rb class Topic < ActiveRecord::Base belongs_to :user belongs_to :board has_many :posts accepts_nested_attributes_for :posts validates :title, presence: true, length: { maximum: 255 } validates :user_id, presence: true validates :board_id, presence: true ... end app/models/post.rb class Post < ActiveRecord::Base belongs_to

Rails RESTful delete in nested resources

空扰寡人 提交于 2019-12-07 19:36:41
问题 Okay, so here's an example scenario. There is a student resource resources :students , and students has and belongs to many collections: resources :clubs , resources :majors , etc. So we can set up our routes easily enough... resources :clubs do resources :students end resources :majors do resources :students end resources :students do resources :clubs resources :majors end which generates us a bunch of standard RESTful routes /clubs /clubs/:id /clubs/:club_id/students /clubs/:club_id

Rails 4, strong parameters, nested resources, build and undefined method permit

醉酒当歌 提交于 2019-12-06 11:21:53
问题 I am unable to get rails 4, strong parameters to work with nested resources via build. Any suggestions would be very welcome. RSPEC shows me Creating Actions Creating an action Failure/Error: click_button "Create Action" NoMethodError: undefined method permit' for "create":String # ./app/controllers/actions_controller.rb:24:in action_params' # ./app/controllers/actions_controller.rb:10:in create' # ./spec/features/creating_actions_spec.rb:16:in block (2 levels) in ' My Browser shows me:

Rails RESTful delete in nested resources

折月煮酒 提交于 2019-12-05 22:32:15
Okay, so here's an example scenario. There is a student resource resources :students , and students has and belongs to many collections: resources :clubs , resources :majors , etc. So we can set up our routes easily enough... resources :clubs do resources :students end resources :majors do resources :students end resources :students do resources :clubs resources :majors end which generates us a bunch of standard RESTful routes /clubs /clubs/:id /clubs/:club_id/students /clubs/:club_id/students/:id /majors /majors/:id /majors/:major_id/students /majors/:major_id/students/:id /students /students