https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
Awesome tool, I plugged into a SQLServer 2008 with little trouble and
figure out how to execute a SP from rails console, but I don’t know where
to go from here 🙁
This seems like a silly question to ask, but I’m pretty new to
development so any help would be greatly appreciated!!
Here’s how I ran the SP (PD_DE_getSegmentProfile) from console:
$ PdDeSegmentMaster.execute_procedure :PD_DE_getSegmentProfile, 23, 'all'
Execute Procedure (49.6ms) EXEC PD_DE_getSegmentProfile 23, 'all'
=> [{"segment_code"=>"23", "profile_element"=>"age_range",
"Value"=>"35-54"}, {"segment_code"=>"23",
"profile_element"=>"avg_HH_size", "Value"=>"4.10"}
I know that’s a hash, but I’ve no idea how to call it from my app,
display it in a view, et cetera. I’m not really concerned with storing
it since I can just recall the SP to get it again. Where do I put the
SP call in the app? Controller? Model?
database.yml, externaldb.rb (model) and the basics needed to set up the connection are all good, just need to move the returned hash to the HTML.
Its best to move business logic to model.
Lets us say you are using the controller “PdDeSegmentMastersController”
In your model “PdDeSegmentMaster”
In your view “get_segment_profile.html.erb”
Let me know if you still have any blocks.