I have the following one to many associations. Document has many Sections and Section has many Items.
class Document < ActiveRecord::Base
has_many :document_sections, :dependent => :destroy, :autosave => true
has_many :document_items, :through => :document_sections
end
class DocumentSection < ActiveRecord::Base
belongs_to :docume...
I'm using asserts_redirected_to in my unit tests, and I'm receiving this warning:
DEPRECATION WARNING: Using assert_redirected_to with partial hash arguments is deprecated. Specify the full set arguments instead.
What is a partial hash argument, and what is a full set argument? These aren't terms that I've seen used in the Rails commu...
how can i get controller B's action in rails specs for controller A?
...
I require a messaging system on my rails app where users need to be able to reply to each other without logging into the site itself. I've seen how this could be done in Basecamp; you simply reply to the email and Basecamp takes care of the rest, forwarding the message to the other parties.
I haven't been able to find any gems/plugins t...
I'm working on a simple timesheet plugin for Redmine, all was going well until I tried to use helpers.
The helper:
module TimesheetHelper
def first_day_in_week(datum)
return unless datum.kind_of? Date
datum - datum.wday
end
def last_day_in_week(datum)
return unless datum.kind_of? Date
datum + (6 - datum.wday)
end
end
In the v...
I have problems to get rspec running properly to test validates_inclusion_of my migration looks like this:
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.string :name
t.integer :parent_id
t.timestamps
end
end
def self.down
drop_table :categories
end
e...
I have code to run sql query in ruby as follows
sql =
ActiveRecord::Base.connection()
sql.begin_db_transaction
report = sql.execute("select * from users;")
sql.commit_db_transaction
So after this report is an Mysql::object. Now I want to extract all fields and its corresponding data to array or hash.
thanks,
...
I have two models:
class User
end
class Message
belongs_to :sender, :class_name=> 'User'
belongs_to :recipient, :class_name=> 'User'
end
I want to fetch all the buddies of a given user ordered by most recent date of message what appears in conversation between given user and his buddy and, if it possible in same query, to fetch the...
I have two MVCs Meeting and Agenda. A meeting can have many agenda items.
I am trying to set these two pages up so that I can click a 'Create New Agenda Item' on the show.html.rb meeting page. The idea being that this would redirect the user to the new.html.rb agenda page passing the meeting id, and pre-populating the new.html.rb agend...
I'm now redirecting to main page in my Rails application using
redirect_to root_path
I want to do the same in jQuery.
i.e. window.location.replace("???");
How to do that?
...
I am using Ruby on Rails and I need to store a search result set obtained by connecting to another server. The problem is I don't want to store the result set in the session and I want something where I can store the result set object over multiple requests.
The querying takes time so I don't want to repeat it. Is there a way I could s...
Hello to All,
We need one voice chat application integration in RoR application existing room users. How we can achieve that? Have any reference links or existing sample voice chat reference sites using mumble, it will help me lot.
Thanks,
Mars
...
I'm using seeds.rb to load some dummy data into my project as I develop it.
I'd like to use a random created_at date for my records, but the created_at date is always set to Time.now on create.
#seeds.rb
Project.create :name => 'Dummy Project',
:created_at => Date.today - rand(10).days
...
I have resque-scheduler working fine in a rails app. Now I need to be able to track status and remove jobs from the queue. I had a brief look at resque-status and, from what I saw, if I could get it to play nicely with resque-scheduler then it would be perfect.
However, it seems rescue-status uses create which wraps enqueue and resque-s...
Hey guys, busy learning ROR... I wasn't quite sure how to look for this problem on stackoverflow so sorry if this has been asked before :p
Basically I'm in the Console environment busy reading all the rows from a table into a variable and I noticed that you can reference the results by specifing my_object.id OR my_object[:id].
Can some...
Hi there,
I need to have a checkbox which ajax-submits a form.
The following code throws an error "index 112009 out of string". What's
wrong here?
<% form_remote_tag :url => { whatever_url } do -%>
<%= check_box_tag 'whatever', nil, whatever, { :onclick => "#{remote_function('this.form.submit();')}" } %>
<% end -%>
Thanks for any ...
The idea is as follows: when visiting a purchase page, the pre-initialized (using before_filter) @purchase variable receives save if the item in question is not free.
I make two gets, one for a paid item and one for a free item. purchase.expects(:save).returns(true) expects :save to be called only once, so the below test works.
But th...
Hey,
I am trying to access an instance variable which is set in the controller in the model. The controller is the products controller and the model is the products model. The instance variable is a instance of another model called account.
The instance variable is @current_account
When I run the code nothing happens, I do not get an ...
We're working on a Ruby on Rails app that needs to take advantage of html5 websockets. At the moment, we have two separate "servers" so to speak: our main app running on nginx+passenger, and a separate server using Pratik Naik's Cramp framework (which is running on Thin) to handle the websocket connections.
Ideally, when it comes time f...
I have a module in my Rails app that lives in /lib
module MyModule
mattr_accessor :the_variable
class << self
def setup
yield this
end
end
end
From my environments/#{RAILS_ENV}.rb file I can then set an environment-specific value for the_variable:
MyModule.setup do |my_module_config|
my_module_config.the_variab...