ruby-on-rails

Mongrel not detecting changes in Rails classes?

I have a Rails app installed on a Slicehost server running Apache 2 and Ubuntu LTC 10.04. Things have worked beautifully up until now: I edit a file, do a quick mongrel_rails cluster::restart, and the changes are reflected in production. However, suddenly this process has broken down. For example, I have a class called Master located i...

Exception pages in development mode take upwards of 15-30 seconds to render, why is that?

I am using Rails 3 beta 4 and for some reason I have each exception taking 15-30 seconds to show. Here is my trace: Started GET "/something/something/approvals/new" for 127.0.0.1 at Thu Jun 24 21:17:12 -0400 2010 SQL (1.8ms) describe `approvals_users` SQL (24.6ms) describe `clients_users` SQL (1.4ms) describe `agencies_users` ...

Custom validation using a file

I have a user sign-up form with a registration code field (:reg_code). I have a list of valid registration codes (in a yml file, but doesn't have to be if that makes things easier). I need to check if the user enters in a valid code in the reg code field. I'm a rails/ruby newbie and have NO CLUE how to load & parse the file to check t...

Ruby on Rails Scaffold - Modify Show Method

Hello, I am a beginner when it comes to Ruby on Rails, so I need a little bit of help. I started reading a basic tutorial recently, which was taught using Scaffolding. I made a "Clients" model: script/generate scaffold clients name:string ip_address:string speed:integer ... Inside the clients_controller.rb file, there is a method called...

Checking validity of message sizes before sending to Twitter...

I have an ActivityStream that sends messages to Twitter. There is a short and long format for each message. It's possible that both could be over 140 chars, but the short format has much lower probability. By default, I start with the long version, then if that is over 140 chars, I use the short version. Again, there's a chance the s...

Follow up to changing Date format from Time.now to post.created_at

I previously asked a question on stack overflow about how to format my date in a readable manner. This was the gist of it was this. How do I take 2010-06-14 19:01:00 UTC and turn it into June 14th, 2010 The answer that I used was calling post.date and simply adding the below to post.rb @date = Time.now @date.strftime("%B %d, %Y"...

Splitting GIF Frames In Ruby on Rails

Hello, SO! I'm messing around with rails and hope to try some different image manipulation techniques. My main goal is to learn more about different image formats and the various ways to interact with them. The first thing I'm attempting to do is split the frames in a GIF image and randomly reorder them into a new image. I've researche...

Converting a String from a Web Form to MongoMapper Model with Array Datatype

I have a MongoMapper model and am trying to convert a comma-delimited string into an Array to be stored. The main problem is that a string such as tags = "first,second,third" is not getting converted to an array in the database like ["first","second","third"]. Instead it is going in as ["first,second,third"]. There are some other stran...

How to write DRY spec for verifying requst parameters

I write spec for controllers in rails application. I want to write DRY spec for verifying request parameters check, rspec can be helpful to use shared_example_for. For example. shared_example_for "verifying request parameters" do it "should return success for required parameter" do get @action, @required_parameters response.sh...

How to install gem pg on Ubuntu

Hi When i try to install postgresSQL gem under Ruby. i issued the following command gem install pg. since i am using Rails 3.0. i installed Ruby9.2 by using RVM. The above command shows me the following error. I have installed all necessary packages and library for postgresSQL under Ubuntu. The error is : Building native extensi...

How to patch a gem to work properly in Rails 3

I am trying to use a particular gem that hasn't been updated since the inception of Rails 3. It makes a reference to RAILS_ROOT when the gem is initialized, which gives me this: can't convert #<Class:0x1018695c8> into String (TypeError) From my understanding, this is because Rails 3 doesn't set Rails.root at this stage of the initiali...

How to make Rails load a plugin *after* the application code?

I'm trying to write a plugin that defines a MongoMapper model. The problem is that when I run script/console, I get this error: /home/helder/.rvm/gems/ruby-1.8.7-p249/gems/mongo_mapper-0.8.2/lib/mongo_mapper/connection.rb:29:in `database':NameError: uninitialized class variable @@database_name in MongoMapper::Connection which leads me ...

Will emails be dropped if a single MX record is missing?

I'd like to setup email using Google Apps for your Domain but can only enter 5 of the 6 required MX records due to limitations with number of host records I can enter (I'm using Zerigo DNS to host my DNS records): aspmx.l.google.com alt1.aspmx.l.google.com alt2.aspmx.l.google.com aspmx2.googlemail.com aspmx3.googlemail.com aspmx4.g...

ImageScience on Mac is not loaded

hi, i'm a ruby-newbe trying to get attachment_fu working (with ImageScience as processor). After few days of exhausting battles I came to the point where (using console): irb> require 'image_science' true so i'm assuming there are no problems with loading. however my application throws constantly: Cannot load file -- image_science ...

sti and has_many problem in rails

register < user admin < user class project has_many :admin, :class => 'User', :conditions => "type = 'admin'" has_many :registers, :class => 'User', :conditions => "type = 'registers'" the problem here is, when I use project to has_many create a register or admin, it doesn't automate fill object class into type filed. like this:...

ruby on rails Model validations with arrays

Hello I have an array of tasks which the user needs to fill, Its looks like this: <% form_for(@task) do |f| %> <%= error_messages_for 'task' %> <ul> <li><label>Task Name</label> <input type=text name="task_list[]"> </li> <li><label>Task Name</label> <input type=text name="task_list[]"> </li> <li><label>Task Name</lab...

How to store the result of my algorithm?

I have an algorithm that searches through all of my sites users, finding those which share a common property with the user using the algorithm (by going to a certain page). It can find multiple users, each can have multiple shared properties. The algorithm works fine, in terms of finding the matches, but I'm having trouble working out ho...

How to Model Multiple Relationships in ActiveRecord?

Hi, I am trying to finish building a Rails "Home Inventory" app as an example to help me learn rails. Following gives a general overview of what I am trying to achieve: The main purpose of this application is to show a page with detailed information. So, http://localhost:3000/living-room-couch would display the information regardin...

How do I set Expires: header when using send_data

I have a method in my controller which uses send_data like this: def show expires_in 10.hours, :public => true send_data my_image_generator, :filename => "image.gif", :type => "image/gif" end Using expires_in results in headers being sent like this: HTTP/1.1 200 OK Connection: close Date: Fri, 25 Jun 2010 10:41:22 GMT ETag: "885d...

Whether or not to modularize with Rails plugins?

I'm working on application which can be logically grouped into a core engine, and business domain modules. The business domain modules essentially encapsulate code which is specific to our customers' businesses. We initially separated this out using the root rails structure for our core engine, and having all customer code in separate ...