ruby-on-rails

MySQL Ruby Gem on OS X Snow Leopard

I've been fighting with getting the MySQL Ruby Gem up and running on Snow Leopard for the past couple of days. I have tried all different sorts of things to get this working, and currently have MySQL 5.1.37 x64 installed. After fighting to even get the Gem installed I believe that I finally got it installed, but whenever I attempt to ac...

Add a red dot and a title to an image

I've got a html-page with a picture on it and would like allow the user to click on the image to add a red dot and a title to the red dot. After adding some dots he should be able to save or print it. What's the best way to implement this with ruby on rails, html, css and (or without) javascript. ...

rails average between multiple models

I've been trying to get my head around doing things using my Rails relationships as opposed to pulling out large SQL joins, but I can't wrap my head around this one... I have 3 models Hotels Rooms Availables They all have the appropriate has_many and belongs_to relationships. What I want to do is on the overview page listing th...

Two related Rails models need to be created at the same time

I have a Map model, which defines the details for an ASCII-art map for a given area in a MUD. I want to be able to reach each map's page using its name instead of its ID, so if I have a map of the Western Ithmia, I want to be able to access it from /maps/western_ithmia (but also /maps/withmia). I have a second model, MapAlias, which con...

gem install mysql problem in rails

Hello, Im getting an error with a rails app. The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. And when i try to do gem install mysql it still doesnt work and im getting this error. WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and ...

Where is a good place for a commonly used method... in rails

I have a method that I've started to use in multiple models for Webscrapping, where is the best place to keep it? Should I put it in the application_controller, application _helper? I'm not sure where a good place is to put it for multiple models to use it? def self.retryable(options = {}, &block) opts = { :tries => 1, :on => Ex...

Undefined method 'make_activation_code' Rails error using Restful_Authentication

I have a fantasy football league rails app that was working last year and it's time to get it going again before the season starts. I cleared out the database and did a "rake db:migrate" so I could restart the app from scratch. The login page comes up fine but when a user tries to "sign up" using restful_authentication I get the followin...

How to get most recent single item from many with ActiveRecord associations?

I'm having some issues with my code. This is probably due to some design fault. I've tried several things. Here are two. Issue: I have a 1 (lending) - N (contracts) relation. I'd like to call lending.current_contract which would return the last relevant contract. Optimization is also an issue. I'd like to call :lending, :include => :con...

Snow Leopard / 64-bit ruby gem problem?

I just upgraded to Snow Leopard, including installing the new XCode, re-compiled Ruby 1.8 and MySQL. My Rails app is running fine in the updated environment, except for some image processing features, which depend on ImageScience/FreeImage. I upgraded MacPorts to 1.8, removed all previously installed ports and reinstalled them in 1.8, ...

Tests pass using "autotest" but not "rake test" using Authlogic

My tests fail when doing "rake test:functionals" but they pass consistently using autotest. The failing tests in question seems to be related to Authlogic not logging in the user properly when using rake. For facilitating signing in a user in tests, I have a test helper method as follows: class ActionController::TestCase def signin(...

refactor conditions within haml view

beside the fact that accessibility standards discourage the use of a link pointing to the current page, how I am supposed to refactor the following view code? #navigation %ul.tabbed - if current_page?(new_profile_path) %li{:class => "current_page_item"} = link_to t("new_profile"), new_profile_path - else %...

New to Rails Help

I have a database query that is returning to a variable which contains an address. @terminal_address = Terminal.find(:all, :select => :full_address ,:conditions => ["id = ?" , params[:id]]) When I pass the @terminal_address to my geocoding code it errors because of how the data is being passed. If I replace the variable with an addres...

rails currency gem or plugin...

I'm shopping for a gem or plugin to help me convert between currencies and handle day to day exchange rate fluctuation. I've found the gem currency: http://currency.rubyforge.org/ And a few other plugins... http://wiki.github.com/jasonfranklin-stokes/currencyexchange & http://jamesbrooks.net/2009/01/05/rails-cash-handler-plugin/ The...

How can I programatically determine which methods have been declared as "helper" methods by a controller in Rails?

I'm writing a plugin that adds a method to controllers and declares it as a helper method. If it were done statically (rather than through the plugin), it would look something like this: # in RAILS_ROOT/app/controllers/stuffed_animals_controller.rb class StuffedAnimalsController < ActionController::Base private def bear 'Teddy...

Rails routing error doesn't recognize id

I have a controller "manage_links.rb" that allows users to manage their links, which have a corresponding "link" model. I am getting the following error: ActionController::RoutingError in Manage_links#index Showing app/views/manage_links/index.html.erb where line #16 raised: edit_manage_link_url failed to generate from {:controller=>...

How do I test helper methods using Shoulda and set the params and request values?

I'm using rails 2.2.2 and wondering how can I set the params values to test my helper methods. I found some examples to let you run tests with helper methods but it doesn't work for me when I use the request or params value directly in the method. require 'test_helper' class ProductHelperTest < Test::Unit::TestCase include ProductHe...

How do you invoke a file download with link_to_remote in rails?

Hi All, I'd like to be able to invoke a file download from rails using link to remote. I have the link working okay,it looks like this : link_to_remote image_tag("icons/ppt_48.png"), :url => formatted_element_path(@element, :ppt), :method => :get, :with => "'stoplight=' + $F('stoplight')" The response contains the proper fi...

Updating a Javascript Variable with AJAX

I am working on a project with FusionCharts that requires me to update a javascript variable with an AJAX request. The FusionChart populates itself with the xml within the 'chart1.setDataXML()' tag as seen below. <div id="barGraph"> Bar Graph </div> <script language="JavaScript"> var chart1= new FusionCharts("/charts/C...

How do I render two html documents per action?

After user push save button, I need to render new page and render_to_string preview of this page in same time. To store it into DB. So i got DoubleRenderError exception. I try to stub @performed? But Layouts purging after first render. Any ideas? Thank you for answers! ...

Is there an alternative to rail's auto_link helper method?

I'm using the auto_link method in Rails to turn urls in plain text to clickable links. It works pretty good most of the time. but google.com doesn't create a link Is there something else out there that provides better coverage of urls? Or is there anyway I can easily modify the Rails code to include .coms and .net without a http or ...