ruby-on-rails

get method for testing in rails

Hi, I'm following along with RailsSpace: Building a Social Networking Website with Ruby on Rails by Michael Hartl. Running rails v2.3.2. I've gotten to the 5th chapter in which testing is introduced. The following is supposed to match the title of the various pages to strings using the get method: require File.dirname(__FILE__) + '/../...

What's the best way to pass in the domain name of your rails server for mailing?

I have an app that has is up in a few environments i.e. (development, staging, beta, live) What's the best way to pass in an app's domain name when sending mail, to allow for different domain names depending on the server? My first thought is to add something in the respective environment.rb files for each one, so config/environments/b...

rails best practice - commit with VCS subversion

What is the best practice for updating a project when you want to roll back a data migration with rails? delete the migration locally and then commit the whole project? ...

template customization / rails reloading

Hi there; I'm looking for giving the ability to user to modify code in a minimal part of a rails app, part that is located in the app directory. I'm stuck with the "not reload anything automatically in production", is there a way to avoid it ? (talking about "user's template customization"; is liquid a way through this problem ? don't s...

exactly what does rake db:migrate do?

Does rake db:migrate only add new migrations, or does it drop all migrations/changes and build everything new? I think rake is throwing an error because it is trying to access a table attribute in migration 040 that was deleted in migration 042. somehow my DB and rake are out of synch and I want to fix them. for you experts out there -...

How can I set the RAILS_ENV in a Windows console?

On Linux and OS X, I'm accustomed to running Rake tasks in specified Rails "environments" by doing this: $ export RAILS_ENV=monster_island ; rake monsters:destroy_all How can I do the equivalent if I'm running the task on Windows XP in a Windows console? ...

Will using an IDE with Rails hinder me?

I'm new to Ruby on Rails and so far, I'm having a lot of fun learning it. Coming from the .NET world, it's been quite a switch as my IDE (Visual Studio 2008) sort of handles everything for me, while in Rails everything has been done via multiple applications (Terminal, TextMate, etc). I've started taking a closer look at RubyMine as an ...

(Ruby,Rails) Multiple simultaneous drag-and-drop items...?

Hi All, I'm looking for a mechanism in Rails by which to facilitate multiple drag-and-drop items simultaneously. Basically I want to select multiple and drag. Obviously I'd prefer to stick with standard HTML items and javascript, but if this isn't possible I'll consider a straightforward Flash implementation. Thoughts? ...

Overriding module in Ruby?

I have this code in vendor/{engine}/app/helpers/application_helper.rb: module ApplicationHelper def application_title() "Foo" end def other_method() # ... end end And this in app/helpers/application_helper.rb: module ApplicationHelper def application_title() "Bar" end end I get "Bar" as expected when callin...

javan-whenever not writing crontab with Capistrano deploy

I’ve been trying to get whenever running on an ec2 instance that was created with ec2 on rails. When I deploy with Capistrano it indicates that the crontab was written, but when I log into the server and run crontab -l it does not seem to have been changed. If I go into the release folder and manually run whenever --write-crontab then...

Array to Active Record Model

Hi everyone! I want to show in a view the tasks for a day in concrete (today). these tasks have an estimated time that must sum 6 hours per day. in the model I have this method: def self.tasks_for_today total_time = 0 r = Array.new all(:conditions => "finished = 0").each do | t | total_time += t.estimated_time r << t if ...

My Rails queries are starting to get complicated, should I switch to raw SQL queries? What do you do?

My Rails app is starting to need complicated queries. Should I just start using raw SQL queries? What is the trend in the Rails community? Update: I do not have written queries right now, I wanted to ask this question before I start. But here is an example of what I want to do: I have books which have categories. I want to say- ...

how to avoid a faulty rollback migration in ruby?

i have a bug in a "self.drop" in a migration such that I cannot roll back past that migration. how can i start from scratch and build up from migration 001? also, is there a way to do this without losing my data (it's just testing, but still...) ...

deploying ruby on rails applications on solaris 10

Is there anyone out there that is currently deploying rails applications on a solaris 10 box? If so can you give me a brief run down of what you had to do to get it up and going? I am a web developer and I am working in a closed environment where they are using sun solaris servers, all of which are for internal use only behind firewall....

Rails migration management - best practices ?

What are best practices for migration management? For instance, when debugging a migration, do you edit the original migration or add an edit migration before committing to the repository? Thanks! ...

pulling 5 field values from a related model

I have reviewrequests that has many sitereviews. I can get at the count of the number of site reviews a given reviewrequest has in a view with: <%=h request.sitereviews.count.to_s %> With each sitereview there's a text field - suggestions. Is there a way to get at say the last 5 sitereview.suggestions values as a single value? Something...

Is there any away to create STI child model objects from the STI base class?

Given the following hierarchy class Content < ActiveRecord::Base end class Page < Content end class Post < Content end Is it possible to create for example, Page content (indirectly) using the following style: c = Content.new c.type = Page c.title = 'test' c.save! Looks like type is also a ruby method on the object. ...

The string "Test '<3'" displays as "Test '<3>" in my Rails app

I'm having a strange problem where a user can enter the following text Test '<3' and it outputs as Test '<3> On the output I'm using white_list, and the value stored in the database is: 'testing ''<3''' What could be causing the output to think it's a tag of some sort and trying to close it (which is what it looks like ...

SQL noob needs help writing a Rails query involving joins and maybe intersect

I have 3 models: Books, Notifications, and NotificationTypes. Books have notifications as the Notification model has a book_id. Notifications have one notification_type as the Notification model has one notification_type_id I want all Books created between date1 and date2 books_set1 = Book.find :all, :conditions => ["created_at <= ? A...

Rails v1.2.3, ActionWebService and .NET platform as client

I'm using Rails 1.2.3 on a project. ( Upgrading rails is not an option ). I've created a simple test web-service using Rails. I've tested using the Rails invoke scaffold. It seems to generate the response with no problems. I'm trying to setup a client via .NET. I've created an ASP.NET Web App project in C#. I am adding a "Web Reference"...