ruby-on-rails

Can't use flash in ActionView::TestCase when I want to test my helper class

I wanted to test a method in my helper class but when I do something like: require 'test_helper' class ApplicationHelperTest < ActionView::TestCase def test_flash_messages flash[:notice] = "Hello World" assert_equal "<div class=\"message-notice\">Hello World<\/div>", flash_messages end end than I get "NoMethodError: undef...

Ruby function Rails XML builder

I want to write a recursive function inside the rails xml builder. Is this possible? Thanks, Abhi ...

rails: how to send the xml page result in a zip file?

Hello everybody, I have a problem with my webservice! As I render xml files just like a web page, the content gets loaded very slowly... Is it possible to render the xml in a zip format? Thanks for any hints concerning this topic! Markus ...

Rails / application.html.erb not loading

Hello! I created a ruby application and the application.html.erb is never loaded (looking at webrick output, I never get "Rendered CLASS/index.html.erb within layouts/application", but "Rendered CLASS/index.html.erb") CLASS.html.erb never gets loaded either. Only when explicitly specifying "render :file => 'layouts/application'" in th...

Changes to the code are not getting reflected in Rails 3.0

Hi, I have started a project using Rails 3.0. I am using devise for the authentication. Devise includes links to signin and forgot password in the sign up page. These links are loaded by means of a partial.I did not need these links, so I removed them and reloaded the page, but still these links remain. I tried clearing the cache and ...

RAILS: paperclip and creation date based directory structure

Hi there, does anyone know how I can configure my rails model, which is using paperclip for data storage, to use creation date based directories like for example in fleximage ?? At present I'm using: has_attached_file :bookblock, :path => "#{CONF['storage_path']}bookblock/:id_partition/:style.:content_type_ehas_attached_filextension" ...

Have a controller send back a response without Content-Type header

I've set up a Rails 3 proxy method inside a controller to use Nginx' X-Accel-Redirect to deliver a specific URI from a remote server if the user is allowed to. Unfortunately, Rails always sends some kind of Content-Type header, which takes precedence over the one returned from the upstream server. I've tried various ways of "convincing"...

ActiveRecord: change and save object state inside model

I have the following code: def incoming_acceptation(incoming_code) if invite_code == incoming_code accepted = true self.save true else false end end But it does not change and save accepted to true, it remains in the previous state, false. @i.incoming_acceptation(incoming_code) => true @i.accep...

rails 3, joining on more three tables

hello I would like joining more three tables in rails 3 my code class offer < ActiveRecord::Base belongs_to :user has_many :usercomments, :dependent => :destroy has_many :comments, :through => :usercomments, :dependent => :destroy end class User < ActiveRecord::Base has_many :usercomments, :dependent =>:destroy has_many...

How to install rails 3.0 on Redhat 4.0 with mysql2 support?

When trying to install rails 3.0 on a redhat 4.0 server, the 'bundle install' fails during the installation of mysql2. Is it possible to solve this? 'bundle install' command returns the following output: ~/rails/trial# bundle install Fetching source index for http://rubygems.org/ Using rake (0.8.7) Using abstract (1.0.0) Using activ...

Cucumber Scenario: Should be listed in chronological order by date in ASC order

Scenario: Events should be listed in chronological order by event date in ASC order How do i test this scenario in cucumber? Events has a name and a event_date. Events is shown in a list in the GUI. I want the test to fail when the events is in a unsorted order and the test to pass when the list is sorted by event_date ASC order. Th...

How to convert time in seconds to standard time format in rails?

Hi, How can convert time in seconds to standard time format in rails.For example 1971 seconds should be displayed as 0:33:25 ...

uninitialized constant Ckeditor::PLUGIN_CONTROLLER_PATH

I've try to use ckeditor in my apps. I followed instruction how to install it, but when I came to this step $ rails generate ckeditor:base I got this error message, uninitialized constant Ckeditor::PLUGIN_CONTROLLER_PATH, and I didn't know to solve it. Does any body know how to solve it? please. ...

Rail performance on ARM

I was wondering if we could replace our Atom N270 based nettops that are running a Rails(ruby 1.8.6...) webapp with some equivalent ARM based device (we like the fanless setup, power consumption, etc.). The ARM device was XScale-PXA270 @ 520, 128MB (and probably some slower SDRAMs), running linux, there was always enough free memory wi...

rails 3.0.1 active_record

How is it possible with active_record? u = User.all u = u.where(:id => 1) NoMethodError: undefined method `where' for # u.class => Array Can't chain conditions :( ...

Simulate clicking the button

How to simulate clicking button outside the form in Rails? This button performs some javascript operations that add some elements to page. How can I test this? ...

rails fields_for with ajax

Hi guys, I am building a dynamic form builder.. And i have a problem which i can't seem to fix. So i have a db table called "forms" forms can have "fields".. The problem is that when a user creates a new 'field' (click add-field) then it should ajax the new field for .. that field. The problem is that i can't just do something l...

What do i build my alpha platform on, PHP, Ruby, Python, .NET, etc?

I am developing a social networking website in the facebook/foursquare-ish space. I have gotten such varied feedback on what platform I should develop in. Of course it will be heavily influenced by who I hire, but i was hoping for a little additional feedback from the larger community. Thanks. ...

Extremely slow bundler 1.0.3 (Bundler.require) with around 100 gems in Rails 3.0.1 and Ruby 1.9.2

I am using Rails 3.0.1, Bundler 1.0.3 and Ruby 1.9.2p0 (2010-08-18 revision 29036). Everything was fine and fast until I started adding Devise & Omniauth. From that on everything involving initializing Bundler (calling Bundler.require as in application.rb) took ages (by means of 30-50 seconds which is a lot for e.g. calling 'rake routes'...

How do you pass options through a fields_for ?

I am trying to run this.. - f.fields_for :referrals do |qf| But I would like to pass this, @organization.referrals.select{|ref|ref.new_record?} as well. This is so that the forms passed are exclusively new objects, and not older ones. I've tried to do this.. - f.fields_for :referrals do |qf| - if qf.object.new_record? = render...