Ruby on Rails Wednesday, June 30, 2010

Srijith nair wrote:
> Hi David
> This error is mainly because your not getting id in the create function
> Please follow the following steps, i think this will solve your problem.
>
> I hope you configured your routes like this
> map.resources :courses do |course|
> course.resources :pages
> end
>
> <%form_for :page,:url=>course_pages_path(@course) do %>
> <%end%>
>
> in controller
> def new
> @course = Course.find(params[:course_id])
> end
>
> def create
> @course = Course.find(params[:course_id])
> @page = @course.pages.find(params[:page])
> end
>
> Keep rocking!
>
> David Zhu wrote:
>> I'm getting this error-
>>
>> ActiveRecord::RecordNotFound in PagesController#create
>>
>> Couldn't find Course without an ID


I have a very similar problem I think. I Can't find Story without an ID.

This is from my email_controller.rb

def correspond
user = @current_user
story = Story.find(params[:id])
recipient = story.user
@title = "Email @current_user.login"
if param_posted?(:message)
@message = Message.new(params[:message])
if @message.valid?
UserMailer.deliver_message(
:user => user,
:recipient => recipient,
:message => @message,
:user_url => user,
:reply_url => url_for(:action => "correspond",
:id => user.login)
)
flash[:notice] = "Email sent."
redirect_to :action => "index", :controller => "stories"
end
end
end

The problem is in the third line.

Any help would be much appreciated.
--
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
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.

No comments:

Post a Comment