ruby-on-rails

bundler with rails 2.3.5 and plugins with 'require'

I'm trying to use bundler with my Rails 2.3.5 app (built off of insoshi) due to some complicated reasons. Basically, I need to deploy to a server that has Rails 2.3.8 and Rails 2.3.5 apps, and they don't play nice with each other because 2.3.8 requires rack 1.1.0, while 2.3.5 requires rack 1.0.1 and blows up if rack 1.1.0 is even instal...

Remote form with A tag submit in Rails 3

Hi guys! I have a remote form with hand-made buttons using tags. I'm using data-remote=true in the form tag, but I don't know how to use the link tag to post the form data in a form submit. When I use data-remote with data-method, it creates a remote call with empty parameters, so I doesn't call the submit() function to my form. My fo...

Add further information to Rails Select list?

Hi Everyone, I have a select list drop down in my Rails application, in the form for creating a new record. <li>Surveyor Name<span><%= f.select :surveyorperson_id, Person.all.collect { |x| [x.personname, x.id]}, {:selected => (@kase.surveyorperson_id rescue "")} %></span></li> This is so the user can choose from a list of Surveyor's ...

Ruby on Rails 3 InvalidAuthenticityToken With REST Calls

Hey Everyone I'm just putting together a simple web application in Ruby on Rails 3 RC and I'm a bit stumped with the forgery protection. I plan to have a web interface as well as allow XML API calls from an iPhone app. I'm currently testing this with a REST request generator but am getting InvalidAuthenticityToken errors. Firstly, I t...

Autoload plugins folder in Rails 3?

The methods in the last two rows in the block are removed in Rails 3. %w{ models controllers }.each do |dir| path = File.join(File.dirname(__FILE__), 'app', dir) $LOAD_PATH << path ActiveSupport::Dependencies.load path ActiveSupport::Dependencies.load_once_paths.delete(path) end I wonder how you could autoload the files in the...

specifying a random association object in factory_girl definition

Is there a way in factory_girl to specify a random instance that an association should point to? For example, I have a Like object which belongs_to one User and one SocialUnit. I want the factory for Like to pick a random existing User and a random SocialUnit to like, instead of just generating a new one. The below snippet sort of wor...

MVC Webframeworks

Possible Duplicate: Choosing a Java Web Framework now? I know that Ruby-on-Rails and Django are 2 MVC oriented webframeworks, in Ruby and Python respectively. Are there any other MVC frameworks ? Any MVC frameworks that use Java ? ...

Moving project from RoR to Symfony - what are the required steps?

I have taken over a medium sized project that was written originally using RoR. The powers that be have decided that they want the web app, 'ported' to Symfony. After looking at some of the RoR code, I suspect that RoR strongly "influenced" Symfony, as a lot of the idioms are shared - so I think that a 'port' of an app from one to the o...

belongs_to association fails to load target parent referred from a setter method on mass assignment

It seems that when a child object has a reference to its parent in its setter, it fails to get initialized unless the foreign key is given first in the parameter hash. class Bot < ActiveRecord::Base has_many :items end class Item < ActiveRecord::Base belongs_to :bot def name=(text) write_attribute(:name, "#{self.bot.name}'s ...

Getting error trying to display string split on new lines - Ruby on Rails

I have the following code: <% @recipe.instructions.each do |instruction| %> <li><%= instruction %></li> <% end %> I get the following error: undefined method 'each' for #<String:0xa354eb8> @recipe.instructions is defined as text Please help! Reese ...

Persisting a shopping cart in Ruby on Rails

Currently developing a shopping cart, the options for persisting the cart, as i see them are: Store the entire cart object in a sessions table. Store the entire cart object in a cookie session. Have a cart table, and store the cart id in a cookie session. Have i missed any? which is the best to roll with please? Thanks ...

how to populate PDF webform with attributes

Have several pdf webforms that I would like to auto-populate with information from my model. Here's a sample pdf http://www.flhsmv.gov/dmv/forms/BTR/Milpak/82040.pdf Is there a gem or plugin that could help? ...

Nested form errors

Hey, I'm putting together a form to create an order, where one order has many order items. I have it working so it lists all the available products with blank quantity fields, and the user can update those fields to order large amounts of each product. I validate the numericality of the quantities in the order item model. The only is...

how to change devise's flash[:notice] in rails

I'm using rails 2.3.5 and devise 1.0.6. I'm having users confirm account's with email. However, when a new user sign's up the flash notice says "The user was successfully created" which it was but it doesn't tell the user that they need to confirm their their email unless they try to log in and devise's flash notice still doesn't explain...

Rails security on production server

I am putting my first rails app on the internet, I have read the rails guide on security and have implemented the points listed in there but was interested to hear of anything else ? Also I currently store my uploads in public/documents is this ok ? I noticed there is no htaccess files protecting the directory. ...

How can I determine the Model by extracting the name of another Model?

I have several models: ContactEmail, ContactLetter, ContactCall My controller doesn't know what is being passed into it. It only knows it as an event (so event can be specific instance of ContactEmail, ContactLetter, ContactCall) Each of these has a different attribute. ContactEmail has email_id; ContactLetter has letter_id, Contact...

Modbus logger into database and array handling strategy

I have found that reading 64 contiguous memory locations (elements) using modbus is the most efficient way of retrieving information over Modbus using the rmodbus library. My goal is to log the read information in a simple database that can be mined to generate graphs and tables of data on a webpage and store the most current value in ...

Avoid rendering comments in HTML

Hi, I have a lot of comments in Rails views. How i can prevent rendering them ? ...

Rails: Conditionally loading associations

Hey! I have models club and course where a course belongs to a club and and a club has many courses. When I load a club, I also want to load it's associated courses, but I only want to load those that meet a conditional test (approved? == true). It is straightforward how to do this if I were working directly with the courses: @course...

action mailer default url options and request host

I am trying to set the :host for action mailer default url options. I have the below set in all the environment files config.action_mailer.default_url_options = { :host => "localhost" } I want to make it more dynamic by providing the request host. when I try to set it by config.action_mailer.default_url_options = { :host => ...