On Jul 2, 2012, at 1:42 PM, sehrguey o. wrote:
> dear Walter,
>
> thank you for your kind attention and readiness to help.
>
> You talked about my controller and proposed an awesomely nice line:
>
> " @foos = Foo.where(["bar LIKE '%?%'",params[:q]])"
>
> Unfortunately, it is not enough to get me started because I can't
> imagine where on earth to stick it into my controller that runs as
> follows:
>
> "class DisksController < ApplicationController
> # GET /disks
> # GET /disks.json
> def index
> @disks = Disk.search(params[:search])
The preceding line is already what I described. You have defined a self.search method in your disk.rb file (or else this line wouldn't work). That seems like you've already got the basics of a search function ready to go. Can I see the content of disk.rb?
Walter
>
> respond_to do |format|
> format.html # index.html.erb
> format.json { render json: @disks }
> end
> end
>
> # GET /disks/1
> # GET /disks/1.json
> def show
> @disk = Disk.find(params[:id])
>
> respond_to do |format|
> format.html # show.html.erb
> format.json { render json: @disk }
> end
> end
>
> # GET /disks/new
> # GET /disks/new.json
> def new
> @disk = Disk.new
>
> respond_to do |format|
> format.html # new.html.erb
> format.json { render json: @disk }
> end
> end
>
> # GET /disks/1/edit
> def edit
> @disk = Disk.find(params[:id])
> end
>
> # POST /disks
> # POST /disks.json
> def create
> @disk = Disk.new(params[:disk])
>
> respond_to do |format|
> if @disk.save
> format.html { redirect_to @disk, notice: 'Disk was successfully
> created.' }
> format.json { render json: @disk, status: :created, location:
> @disk }
> else
> format.html { render action: "new" }
> format.json { render json: @disk.errors, status:
> :unprocessable_entity }
> end
> end
> end
>
> # PUT /disks/1
> # PUT /disks/1.json
> def update
> @disk = Disk.find(params[:id])
>
> respond_to do |format|
> if @disk.update_attributes(params[:disk])
> format.html { redirect_to @disk, notice: 'Disk was successfully
> updated.' }
> format.json { head :no_content }
> else
> format.html { render action: "edit" }
> format.json { render json: @disk.errors, status:
> :unprocessable_entity }
> end
> end
> end
>
> # DELETE /disks/1
> # DELETE /disks/1.json
> def destroy
> @disk = Disk.find(params[:id])
> @disk.destroy
>
> respond_to do |format|
> format.html { redirect_to disks_url }
> format.json { head :no_content }
> end
> end
> end"
>
> yours`
> sehrguey
>
> --
> 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