Passing json parameter in ruby on rails

Just i called one function in my program, but i need to pass one
json parameter…But getting the error like
ArgumentError (Unknown key: branch_id):
*
*
CODE
*
*
*branch1(params[:branch])
*
*
*
*def branch1(branch)
*

  • branch123 = Branch.find(params[:branch])

end
*
*
And my rest-client body is

*{“user”:
{“password”:“password”,“user_name”:“user2”},“branch”:{“branch_id”:“1”}}
*

On 3 April 2012 12:55, amvis [email protected] wrote:

end

And my rest-client body is

{“user”:
{“password”:“password”,“user_name”:“user2”},“branch”:{“branch_id”:“1”}}

Do you mean that is the value of params? If so then params[:branch]
is a hash rather than a id value. Perhaps you mean
find(params[:branch][:branch_id]), or perhaps I misunderstand what you
are trying to do.

Colin

http://groups.google.com/group/rubyonrails-talk?hl=en.

gplus.to/clanlaw

i need to get the values from the :branch. so when i call the function
*
authenticate_for_branch*, how to pass that branch and accept that…?
Thank you
vishnu

Hi,

Get the data of
branch=params[:branch] [:branch_id] unless params[:branch].nil?

send this branch to the method.

On Tue, Apr 3, 2012 at 5:48 PM, amvis [email protected] wrote:

On 3 April 2012 12:55, amvis [email protected] wrote:

end
are trying to do.
.
gplus.to/clanlaw
http://groups.google.com/group/rubyonrails-talk?hl=en.


Thanks & Regards,
MuraliDharaRao.T
+91-9642234646