In this article i am going to explain one problem on active resource custom calls on get method and what the solution on that. Lets see whats the problem while you are making any active resource get calls. Lets see one example code snippet.
Key Point: The objects returned from the called methods will be just ordinary hash only. It will not be automatically converted into ActiveResource::Base instances.
If you are expecting ActiveResource::Base instances, you have to use "find" class methods with ":from" option. This is the solution for the problem.
Then the new method will be like this
User.find(:all,:from=> :active) # GET /users/active.json
# => <#User...> <#User...>.... (result as ActiveResource::Base instances).
Then you can use inside the iterations user.first.login_name something like this.
Thanks for reading this article. Hope it will be useful for you.
User.get(:active) # GET /users/active.json # => [{:id => 1, :name => 'Madhan'}, {:id => 2, :name => 'Ayyasamy'}] User.get(:active, :awesome => true) # GET /users/active.json?awesome=true # => [{:id => 1, :name => 'Madhan'}]
Key Point: The objects returned from the called methods will be just ordinary hash only. It will not be automatically converted into ActiveResource::Base instances.
If you are expecting ActiveResource::Base instances, you have to use "find" class methods with ":from" option. This is the solution for the problem.
Then the new method will be like this
User.find(:all,:from=> :active) # GET /users/active.json
# => <#User...> <#User...>.... (result as ActiveResource::Base instances).
Then you can use inside the iterations user.first.login_name something like this.
Thanks for reading this article. Hope it will be useful for you.
It was really a nice article and i was really impressed by reading this
ReplyDeleteRuby on Rails Online Training
Thanks for sharing this wonderful article, Its very informative. Read Also.. How to Connect My Epson Printer to a Wired Network?
ReplyDeleteI truly like to reading your post. Thank you so much for taking the time to share such a nice information Steps To Disable Avast Antivirus
ReplyDeleteHey admin, I found some really interesting things. Thank you so much for sharing this.. Also read this.. Choose Best Tech Blogs
ReplyDeleteThanks for sharing this post and its very helpfu, Also Check this How To Enable And Disable YouTube Restricted Mode On Microsoft Edge?
ReplyDeleteI truly like to reading your post. Thank you so much for taking the time to share such a nice information Here’s How You Can Use PIP Mode in Chrome, Edge, and Firefox
ReplyDeleteHey! I was just exploring and came across your site. The articles and blogs were quite interesting to read. I am from technological field. If someone is interested to read about Antivirus software, then do visit my site
ReplyDeletemcafee.com/activate or
norton.com/setup
office.com/setup