ruby-on-rails

How can I create a form in Rails without having to use form_for and a model instance?

First of all, I'm a Rails newbie. I can hold my own in Ruby, but Rails is a whole different story for me. I like the development speed Rails offers me, but I can't seem to make peace with the existing documentation. For all of my forms so far, I used form_for, with an instance for the model I needed to create ( for example, submitting a...

Where should I put SQL queries in Rails?

What is the best practice where should I put SQL queries in Rails? Should I create the methods in models for example: find_all_public_items where I'm using the find methods with all the conditions, and then using them in controllers. Like that I have all the queries in one place but I miss the flexibility that every query should be exa...

Is feasible to develop in Ruby on Rails with limited resources?

I don't know Ruby on Rails and I want to learn it doing something. A very small project was proposed to me, and I was wondering if I could implement it in Ruby on Rails, since I have limited resources. The office where I should programm doesn't have an internet connection at all, and the hardware is a few years old (Intel Celeron 2.63 G...

ruby development environment

is it better to develop ruby on rails in a) windows b) linux or c) mac. why ? edited : the reason why i am asking this is that i heard that developing ruby on rails in windows is not as stable/good compared when you used ruby on rails in mac. (not sure though if that is true or not). plus the fact that David Heinemeier Hansson (cre...

How do I use CSS with a ruby on rails application?

How do I use CSS with RoR? When I link externally, I'm never able to see the files. I cp'd the .css file to every folder I could think of...views, controller, template, and nothing seems to work. What do I need to do to enable external CSS files with a rails application? I'm new to rails, so forgive me if this is basic. Solution: P...

Is there any disadvantage to using both MacPorts and RubyGems at the same time?

I'm new to Ruby on Rails, and I'm in the process of setting it up on my OS X system. Most guides seem to recommend using MacPorts to install Ruby and RubyGems, then using RubyGems from there on to install gems. I've noticed that MacPorts also offers many gems (though they're missing some and others seem a few releases behind), and I'm wo...

DRY Rails Master Templates?

Is there a simple way to define a master template for my whole rails application? If not, what's the best way to reuse my templates so that I'm not copy and pasting the same template into a bunch of layout files? ...

Making custom changes to AssetTagHelper into a plugin

I have written some custom code that make changes to some of the methods in ActionView::Helpers::AssetTagHelper An example: module ActionView module Helpers module AssetTagHelper alias old_existing_method existing_method def existing_method puts "Does foobar" return old_existing_method end en...

Getting a NameError with ActiveRecord and relationships

I've run into a problem when using a one to many relationship. I want to have each Series have one Publisher and that one Publisher has many Series. This is my Publisher model: class Publisher < ActiveRecord::Base validates_presence_of :name has_many :series end This is my Serie model: class Serie < ActiveRecord::Base belongs_...

Integrate test process with Rspec and Cucumber in a plugin using Desert

Hello, I'm developing some rails plugins with desert, and I would like to use tests with RSpec and Cucumber in the development. RSpec is integrated by default in Desert plugins, but it gives me some bugs. Finally I have created a minimal application which use my plugin, and I try to test it like a normal application without plugin. But I...

Posting a form from Rails programatically

How would I go about creating and posting a form POST request from inside some Rails code? The use case I have is that I have received a form request, and I would like to forward this request on to a third party with my parameters intact. I should add that I want to redirect the user out to the third party with the form too. ...

How can I run Rails "script/[xyz]" commands on Windows?

I am used to doing Rails development work on a Mac. However, now other developers will be working with me and they use Windows, both XP and Vista. I am trying to figure out the Windows environment so I can help them. In OS X and Linux you have this kind of thing... $ cd [Rails project root] $ script/console Tried it on Windows but al...

Fully custom validation error message with Rails

Using Rails I'm trying to get an error message like "The song field can't be empty" on save. Doing the following: validates_presence_of :song_rep_xyz, :message => "can't be empty" ... only displays "Song Rep XYW can't be empty", which is not good because the title of the field is not user friendly. How can I change the title of the fi...

debugging a rails controller making too many queries

Hi All, I have a rails application that about 3 years old, and I'm having a problem with my pages making too many queries. Every page that loads has several lines that look like this: ReqTdsLink Columns (1.0ms) SHOW FIELDS FROM `req_tds_links` what sort of method call would cause this output in the log? I can't find any before fil...

is it possible to start the Rails console from within your code?

I know of the ruby gem "ruby-debug" that allows you to place a debugger call inside your code. Using it, it's possible to have breakpoints in your code. I used script/console a bit for some tests, and I would like to know if I can call it from my code. Thanks ! EDIT: here is some sample ruby code require "ruby-debug" [1,2,3,4,5]....

how to optimise site load times in ruby?

I'm a newbie who is creating a lightweight photo showcase site written on the cake php framework with RoR.i plan to use effects from the scriptalicious library, as well as jquery for photo display & transition effects. As the site will be very photo-rich, what programming steps can i take to ensure that all photos and other pages load q...

What's the correct way to run one controller action from another controller action without an HTTP redirect?

I'd like to be able to dispatch from one controller action to another conditionally, based on a combination of query parameters and data in the database. What I have right now is something like: class OldController < ApplicationController def old_controller_action if should_use_new_controller new_params = params.dup n...

How to design different 'views' of a model RESTfully?

By 'view' here I mean different combinations of properties of the model, not the view of the traditional MVC. For example, I have the following model: class Game < ActiveRecord::Base has_many :players belongs_to :status has_one :deck has_many :turns has_one :current_turn, :class_name => 'Turn', :conditions => ['turn_num = ?', ...

Best way to implement an "endless page" in rails?

Pagination sucks! The user should be able to scroll down forever, automatically pulling in new content when appropriate. There's a decent rails cast about this, but Ryan admits that his solution won't work in IE. What's the best way to accomplish this in Rails (preferably in a jQuery-friendly fashion)? ...

Unit conversion causing problem when data returned to the browser after form submit -- Ruby on Rails

Background, Part 1 I have a form that collects both frequency and duration from the user. We set both the frequency and the duration in seconds, but, to the user, they are always presented as days or weeks. For example, the user sees "every other day", but the value set on the option is '172800' as that is the number of seconds in 2 days...