In the view you can run <%= debug(@masterkey) %> to inspect the
object, which will probably give you a clue to what the problem is

On Apr 16, 2:05 pm, Sandeep Ndd <[email protected]> wrote:
> undefined method `pin' for "Masterkey_2304":String
>
> Extracted source (around line #3):
>
> 1: <p>
> 2:   <b>Pin:</b>
> 3:   <%=h @masterkey.pin %>
> 4: </p>
> 5:
> 6: <p>
> RAILS_ROOT: D:/CRIMPROF
> Request
>
> Parameters:
>
> {"Search"=>"Search",
>  "pin"=>"2304"}
> Response
>
> Headers:
>
> {"Content-Type"=>"text/html",
>  "Cache-Control"=>"no-cache"}
> please find the problem and my model looks like....
> class Masterkey < ActiveRecord::Base
>   has_one :crimprofs
>   set_table_name "MASTERKEY"
>   set_primary_key :pin
>   def self.find_all_elements(masterkey)
>     tablename2 = masterkey
>     find_by_sql ['SELECT * FROM ?',tablename2]
>   end
>
>   validates_uniqueness_of :pin, :scope => :pin
> end
> and My Controller looks like
> class MasterkeysController < ApplicationController
>   protect_from_forgery :only => [:create, :delete, :update]
>
>   # GET /masterkeys
>   # GET /masterkeys.xml
>   def index
>     @masterkeys = Masterkey.all
>     respond_to do |format|
>       format.html # index.html.erb
>       format.xml  { render :xml => @masterkeys }
>     end
>
>   end
>
>   # GET /masterkeys/1
>   # GET /masterkeys/1.xml
>   def show
>     @masterkey = Masterkey.find(params[:id ])
>     @rcn = @masterkey.rcn
>     puts params[:id ]
>     puts @rcn
>     respond_to do |format|
>       format.html # show.html.erb
>       format.xml  { render :xml => @masterkey }
>     end
>   end
>
>   # GET /masterkeys/new
>   # GET /masterkeys/new.xml
>   def new
>     @masterkey = Masterkey.new
>
>     respond_to do |format|
>       format.html # new.html.erb
>       format.xml  { render :xml => @masterkey }
>     end
>   end
>
>   # GET /masterkeys/1/edit
>   def edit
>     @masterkey = Masterkey.find(params[:id])
>   end
>
>   # POST /masterkeys
>   # POST /masterkeys.xml
>   def create
>       hashMaster = params[:masterkey]
>     @masterkey = Masterkey.new()
>     @masterkey.pin=hashMaster[:pin]
>     �[email protected] = hashMaster[:rcn]
>     respond_to do |format|
>       if @masterkey.save
>         flash[:notice] = 'Masterkey was successfully created.'
>         format.html { redirect_to(@masterkey) }
>         format.xml  { render :xml => @masterkey, :status => :created,
> :location => @masterkey }
>       else
>         format.html { render :action => "new" }
>         format.xml  { render :xml => @masterkey.errors, :status =>
> :unprocessable_entity }
>       end
>     end
>   end
>
>   # PUT /masterkeys/1
>   # PUT /masterkeys/1.xml
>   def update
>     @masterkey = Masterkey.find(params[:id])
>
>     respond_to do |format|
>       if @masterkey.update_attributes(params[:masterkey])
>         flash[:notice] = 'Masterkey was successfully updated.'
>         format.html { redirect_to(@masterkey) }
>         format.xml  { head :ok }
>       else
>         format.html { render :action => "edit" }
>         format.xml  { render :xml => @masterkey.errors, :status =>
> :unprocessable_entity }
>       end
>     end
>   end
>
>   # DELETE /masterkeys/1
>   # DELETE /masterkeys/1.xml
>   def destroy
>     @masterkey = Masterkey.find(params[:id])
>     @masterkey.destroy
>
>     respond_to do |format|
>       format.html { redirect_to(masterkeys_url) }
>       format.xml  { head :ok }
>     end
>   end
>   def search
>     pin_id= params[:pin]
>     pin = pin_id.to_i
>     @pin = Masterkey.find(pin)
>     @masterkey = "[email protected]}"
>     puts @pin
>
>     @rcn = Masterkey.find_by_sql ("select rcn from masterkey where pin
> =" + pin_id)
>     puts @rcn
>     respond_to do |format|
>       format.html
>       format.xml  { render :xml => @masterkey }
>     end
>   end
> end
> --
> Posted viahttp://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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to