ruby-on-rails

undefined method `layout' for #<HelloController:0x101d7edb0> from Controller

I was trying to switch the layout using Ruby on Rails but I am getting the error: undefined method `layout' for #. I am using Rails 2.3.5 Am I missing an include? Here is the code: class HelloController < ApplicationController def index layout 'standard' @message = "Goodbye!" @count = 3 @bonus = "This is the bonus m...

Using God to monitor Unicorn - Start exited with non-zero code = 1

Hello, I am working on a God script to monitor my Unicorns. I started with GitHub's examples script and have been modifying it to match my server configuration. Once God is running, commands such as god stop unicorn and god restart unicorn work just fine. However, god start unicorn results in WARN: unicorn start command exited with ...

No foreign key in new scaffold

Good day... I have huge trouble with this and it drives me insane. My user creation should have some additional data, like this: <div class="field"><%= label_tag 'species', %> <%= f.collection_select :species_id, Species.all, :id, :name %></div> It displays the list of species correctly, yes, but when I do a submit, it is utterly...

How can I programmatically replace the contents of the current db with a .sqlite3 file in a rails app running on heroku?

When a certain request hits my app I would like to reset the database back to its original state which is backed up in an sqlite3 file. I'd appreciate any help. The app is hosted on heroku. ...

update_attributes not working for many-to-many nested attributes

I have some nested attributes in some models as such: class Employee < ActiveRecord::Base has_one :user, :as => :user_role, :dependent => :destroy accepts_nested_attributes_for :user, :allow_destroy => true end class User < ActiveRecord::Base has_one :person, :as => :person_role, :dependent => :destroy belongs_to :user_role, :p...

Can I use a text file as my database in ROR?

I would like to use a delimited text file (xml/csv etc) as a replacement for a database within Ruby on Rails. Solutions? (This is a class project requirement, I would much rather use a database if I had the choice.) I'm fine serializing the data and sending it to the text file myself. ...

Installing weborb for rails - permission denied

I'm trying to install weborb for rails on windows xp, rails 2.3.8 I type in my project directory: ruby script plugin install http://themidnightcoders.net:8089/svn/weborb and i get the error: ruby: Permission denied -- script (Load Error) Any ideas out there? Thanks in advance. ...

Receiving this odd error with Vagrant, wondering if someone could lend a hand

Hi, I am trying to set up Vagrant. I am following the guide on the web site and currently have trouble with the Provisioning part of the guide (http://vagrantup.com/docs/getting-started/provisioning.html) I have followed this thing to exactly as it is on the site but I am receiving this error, I am on Mac OSX if it's of any important e...

Where should I store calculated values I use throughout my application in Rails?

I have the following variable definition: @monday = (Time.now).at_beginning_of_week I use that in different models, controllers, and views. Where can I define it (and how should I define it -- @@? ) so I can define it once and use throughout my Rails application? Should it be in environment.rb? Should it be a @@? ...

How to get mongrel working with bundler?

Transitioning to bundler with an existing production setup. Naively with a gemfile and setup like: gem "rails", "2.3.8" gem "mongrel", git: "http://github.com/dynamix/mongrel.git" bundle install --path /mnt/app/shared/bundle Starting with bundle exec mongrel_rails start --environment=production ... results in /mnt/app/shared/bun...

Rails: Mechanize throwing 405 HTTPMethodNotAllowed error

I'm using Mechanize to try and login to http://fedex.com but doing so keeps returning this error: 405 => Net::HTTPMethodNotAllowed Is that a response from fedex.com? Any ideas how to get around it? Here's my Mechanize code: agent = Mechanize.new { |a| a.log = Logger.new("mech.log") } agent.user_agent_alias = 'Mac Safari' page = agent...

rails markitup/markdown or textile

I would like to give my user's the option to nicely format their comments. I am not really looking for something super fancy, perhaps something lightweight. There is a ton of information about markup/markdown/texttile etc. Which it the way to go in rails, performance and usability, compatibility with jquery, security being the priority...

Rails - how to pull specific sorted data out of database

Hey all, I have a database with columns (username, points). I am making a call to return some fields from this database to use in a program. I want to pull: The top 10 users with the most points The 5 users above/below the username requesting the rankings I can pull the top 10 easily enough... top_users = UserPoints.find( :all, ...

How do I find all the records regardless of case..

What can i do you find a case insensitive search >> Band.find_by_name("metallica") => nil >> Band.find_by_name("Metallica") => #<Band id: 3, name: "Metallica", created_at: "2010-10-03 01:17:24", updated_at: "2010-10-03 01:17:24", user_id: "4"> I need to find the record in both cases...any suggestions? ...

RSpec-2 and Devise

Hi, i create a customized devise registration controller and i want to test it with rspec. I've tried it with a very simple test : it "creates a new parent" do Parent.should receive(:new) post :create end but i get this exception: Failures: 1) Parent::RegistrationsController POST create creates a new parent Failure/Error:...

Create a website that lets users create a website?

I have always written websites that interact with the endusers directly. Now I want to create a website that lets users create their own websites - from scratch. Almost like Drupal online, I provide all the unit blocks for them to use to build their own website. They just drag and drop text fields, buttons, (div) containers etc. I hav...

How can I count and filter on an associated record in Rails?

Company has_many Contacts Company has_many ContactEmails :through => :contacts ContactEmail belongs_to Contact Contact belongs_to Company Contact has_many ContactEmails For a specific instance of Company, how can I find all ContactEmails and filter on an attribute, such as date_sent? I tried Company.ContactEmails but I don't think ...

Ruby 1.9.2, Rails 3 Console: Not enough memory??

I just upgraded to Rails 3, and in the last 24 hours I have started to see a new error message popping up in my console: Errno::ENOMEM: Not enough space - <STDOUT> from C:/Sanj/Ruby192/lib/ruby/1.9.1/irb.rb:311:in `write' from C:/Sanj/Ruby192/lib/ruby/1.9.1/irb.rb:311:in `printf' from C:/Sanj/Ruby192/lib/ruby/1.9.1/irb.rb:311:in `output...

Books for Ruby On Rails With Facebook Platform!

Hey guys! do you know good books for Ruby On Rails With Facebook Platform. please suggest some good books for Ruby On Rails With Facebook Platform! ...

calling actions in other controller.

Hi all, I have a controller called twits controller .. here i have few actions to communicate with the 3rd party API.. it has few actions to authenticate and few actions to get some values with the help of API. Now i have another controller called home and in the index page of this controller i have to call the actions of the twits cont...