Ruby on rails

Chartkick and groupdate gems are show only one point at graph, graph should be several lines

I create ruby on rails app to show stock value for some companies at some time period. I use next gems: chartkick, groupdate and stock_quote My Shema.db: create_table “companies”, force: :cascade do |t| t.string “symbol” t.datetime “current_date” t.float “value” t.datetime “created_at”, null: false t.datetime “updated_at”, null: false end Fill database with seeds.rb: Company.delete_all d1 = Date.new(2014, 9, 1) d2 =…
Read more

Naming Convention for Null Objects in Rails?

For rails applications: does there exist a naming convention for naming your null objects that are mapped to model objects? Example: #app/models/blog.rb class Blog < ActiveRecord::Base end #app/models/null_blog.rb class NullBlog # Null Objects are POROs, correct? def title “No title” end end # so to implement it I can do this: blogs = ids.map{|id| Blog.find(id) || NullBlog.new} # which allows…
Read more

Update config at redis with locks

I got few service instances, each of which at start should update config at Redis with its queue name or create config at redis if it doesn’t exist: When the first service instance starts it should create a config with 1 item: my_service_queues: [ ‘queue_1’ ] when the second and third service start they should update the config to that:…
Read more

Rails nested forms headache – following RailsCast 196

This has been doing my head in for hours and I think I can safely say I cannot solve it. I was trying to follow this railscast in our project: http://railscasts.com/episodes/196-nested-model-form-revised It’s really simple. A has_many relationship and the ability to add/remove the related model. Assets are related to a client_schedule through the asset_client_schedule Firstly, no matter if I prepopulate…
Read more

Ruby On Rails before_filter called twice?

When I send an ajax request to my ruby controller, the before_filter function seems to be called twice for each ajax request. I use the before_filter for authentication. The ajax request I use: $.ajax({ type: ‘GET’, url: ‘URL_TO__RoR_Controller’, username: username, password: password, contentType: “application/json; charset=utf-8”, success: function(data){ console.log(data); }, error: function(xhr, ajaxOptions, thrownError) { console.log(arguments); } }); The RoR code:…
Read more

RSpec: how can I spy on interactions with an existing object?

I have an existing stub object, that I am using as a collaborator in my tests: cf_client = Aws::CloudFormation::Client.new(:stub_responses => true) stack = described_class.new(“name”, cf_client) The stub object (cf_client) was not created using rspec-mocks; it’s a fake implementation provided by the aws-sdk gem, and has useful properties. However, it doesn’t provide message verification, so I am hoping to wrap in…
Read more

How can I kill process, which has spawned a child using system()?

I’m using Cygwin on Windows 7 (though the same problem could perhaps also apply to a native Linux environment). A parent process – which happens to be a Ruby program, but I guess the same problem would occur, if this were a pure C application – uses system() to execute an external (possibly long-running) command. While this external program is…
Read more