Hi, I’m a PHP programmer doing my first post-Agile rails project and I
am having major issues understanding how to handle associations and
utilize GET/POST params in rails.
The particulars are as follows:
The site consists of Articles. Each article may have many pages.
Each page has an corresponding article_id which assigns it to an
Now my problems arise when I try to pass that article_id into the “Add
new page” form. I (assume I) need that article_id to be part of the form
so that it will be passed to the create action. I would also like to use
that article_id to access that article’s information so I can display
the Article’s title for the user.
I currently have the new_page (form) and create_page actions in the
Article controller. Perhaps this is a structural problem?
class Article < ActiveRecord::Base
class ArticlePage < ActiveRecord::Base
Article Controller (edited):
class ArticlesController < ApplicationController
Article actions removed for
Article Page actions
#@session[:article_id] = @params[:article_id]
#@article_page = ArticlePage.new
#@article = Article.find(params[:article_id]
@article_page = ArticlePage.new
# how do I pass that article_id parameter into the form?
@article = Article.find params[:article_id]
flash[:notice] = ‘Page was successfully added to this article.’
render :action => ‘show’
I would appreciate any help, advice, guidance on this subject as to the
approach to take when faced with this situation.