On 4 July 2012 01:35, cyber c. <lists@ruby-forum.com> wrote:
> Hi Colin,
Please remember to quote the previous post when replying, I have just
had to look back at the previous email to find what I suggested last
time. This is a mailing list not a forum, though you may be accessing
it via a forum style interface.
>
> Thanks for the response . I have spent enough time debugging my rails
> app and found that the default code generated by the rails itself is
> buggy.
> I have created a new scaffold for the resource Trial. After
> creating a new entry, the index page of the resource shows up stale
> data. (I start creating a new record, i get a message record created
> successfully, only to see that the index page doesnt show up any
> record). I had put up print statement in the controller index and saw
> that the statement "@trails = Trial.all" returns nothing.
Did you mean @trials rather then @trails?
> But if i do a
> "rake db:migrate" (which i dont have to do) the updated data shows up.
Have a look in development.log to see if there are any clues there.
If you can't see anything post the section of the log starting with
the GET for trials/new, through the create and ending with the index
request.
Colin
>
> Any help on this is greatly appreciated. Please let me know if you need
> any info.
>
> Im using rails version 3.2.4
> My class controller
>
> Class TrialsController < ApplicationController
> # GET /trials
> # GET /trials.json
> def index
> @trials = Trial.all
>
> respond_to do |format|
> format.html # index.html.erb
> format.json { render :json => @trials }
> end
> end
>
> # GET /trials/1
> # GET /trials/1.json
> def show
> @trial = Trial.find(params[:id])
>
> respond_to do |format|
> format.html # show.html.erb
> format.json { render :json => @trial }
> end
> end
>
> # GET /trials/new
> # GET /trials/new.json
> def new
> @trial = Trial.new
>
> respond_to do |format|
> format.html # new.html.erb
> format.json { render :json => @trial }
> end
> end
>
> # GET /trials/1/edit
> def edit
> @trial = Trial.find(params[:id])
> end
>
> # POST /trials
> # POST /trials.json
> def create
> @trial = Trial.new(params[:trial])
>
> respond_to do |format|
> if @trial.save
> format.html { redirect_to @trial, :notice => 'Trial was
> successfully created.' }
> format.json { render :json => @trial, :status => :created,
> :location => @trial }
> else
> format.html { render :action => "new" }
> format.json { render :json => @trial.errors, :status =>
> :unprocessable_entity }
>
> end
> end
> end
>
> # PUT /trials/1
> # PUT /trials/1.json
> def update
> @trial = Trial.find(params[:id])
>
> respond_to do |format|
> if @trial.update_attributes(params[:trial])
> format.html { redirect_to @trial, :notice => 'Trial was
> successfully updated.' }
> format.json { head :no_content }
> else
> format.html { render :action => "edit" }
> format.json { render :json => @trial.errors, :status =>
> :unprocessable_entity }
> end
> end
> end
>
> # DELETE /trials/1
> # DELETE /trials/1.json
> def destroy
> @trial = Trial.find(params[:id])
> @trial.destroy
>
> respond_to do |format|
> format.html { redirect_to trials_url }
> format.json { head :no_content }
> end
> end
> end
>
> --
> 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-US.
>
--
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-US.
No comments:
Post a Comment