BC2
BC2

Reputation: 1129

undefined method `save' for 15:Fixnum

I'm following this tutorial, http://guides.rubyonrails.org/ . In the tutorial, the examples just accept input from user and it's done. But in my code, after receiving input, i would need to get the result by calling the function defined in my ResultModel. THe below code doesn't execute the function but str8 save the input i entered(ncbi_ref_seq). What i need is to process the input by calling the function generate_result(result_params) and then only save. How can i do that ?

What i need to get from the function is genome_seq ,genome_sample and binding times which it will refer to NCBI_ref_seq ( the 1 i key in the form )

def create
    @generator = Generator.find(params[:generator_id])
    @result = @generator.results.create(params[:result])
    @[email protected]_result(result_params)
    @result= @result.save
    redirect_to generator_path(@post)
  end



def generate_result(result_params)
    ref_seq = self.ncbi_ref_seq
    Bio::NCBI.default_email = "[email protected]"
    fasta_sequence = Bio::NCBI::REST::EFetch.nucleotide(ref_seq,"fasta")
    fasta=Bio::FastaFormat.new(fasta_sequence)
    self.genome_seq = fasta.data
    self.genome_sample = fasta.definition    

    g=Generator.last
    p=self.genome_seq.scan(g.c_primer)
    self.binding_times= p.length()    
end

Upvotes: 0

Views: 532

Answers (1)

BvuRVKyUVlViVIc7
BvuRVKyUVlViVIc7

Reputation: 11811

The last line returns the last used object... So you returned self.binding_times= p.length()
If you add self at the end, it should work

def generate_result(result_params)
    ref_seq = self.ncbi_ref_seq
    Bio::NCBI.default_email = "[email protected]"
    fasta_sequence = Bio::NCBI::REST::EFetch.nucleotide(ref_seq,"fasta")
    fasta=Bio::FastaFormat.new(fasta_sequence)
    self.genome_seq = fasta.data
    self.genome_sample = fasta.definition    

    g=Generator.last
    p=self.genome_seq.scan(g.c_primer)
    self.binding_times= p.length()    
    self
end

Upvotes: 1

Related Questions