ruby-on-rails

cannot install rails plugins

My problem is: ruby script/plugin is not working (I don't see any HTTP traffic, nor an error message or something) What can be failing? Did I forget to setup something? My progress so far (using Windows XP): Unpacked hxxp://files.rubyforge.vm.bytemark.co.uk/rubyinstaller/ruby-1.9.1-p378-i386-mingw32.7z (to d:\prog\Ruby) Unpacked hxxp:...

Why does my rails project not have the ruby standard lib in $LOAD_PATH on OSX?

I need to do a: require 'generator' Inside of a rails project, but it is not working for me on OSX, because the ruby standard library (which is located in my /usr/lib/ruby/1.8) is not in my $LOAD_PATH once rails boots. If I just run irb outside of rails it is there. Where/What do I need to config? ...

In Rails, how to create a dropdown menu that fills in parameters to a path to navigate to?

Trying to create a select menu with items from a collection, so that upon selection of an item, and hitting submit, the user is taken to the "Show" action for that item...What I have is something like this: <% form_tag("subjects/#{@subject.id}/state/:id", :method=>:get) do %> <%= select_tag('state', options_from_collection_for_select(...

Data integrity when updating/incrementing values in Rails

I am working on an application in which one module accesses a log (an ActiveRecord model) to increment various values at several points of the execution. The problem is that the script is likely to take several seconds, and other instances of the same script is likely to run at the same time. What I'm seeing is that while the script fin...

Why am I getting a load_without_new_constant_marking exception?

If I do the following: $SAFE = 1 begin load(untrusted_file, true) rescue Exception => exc logger.info "Exception handled(#{exc.inspect})!\n #{[email protected]("\n")}" end I get a load_without_new_constant_marking exception(removing $SAFE=1 solves it). Why am I getting this exception? Nothing in the untrusted code(contrary to the nam...

Ruby on Rails: Once you've eager loaded an association that has conditions, how can you get at it without touching the database again?

Imagine a simple case like this: class Book has_many :chapters end Let's say in my controller I do something like this: book = Book.find(:first, :include => :chapters, :conditions => ['chapters.title = ?', "In the beginning"] Now let's say I want to display the chapter. How can I address the c...

issue integrating flex with ruby on rails

Hello, I'm having an issue integrating flex with ruby on rails. I get this error: ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): <internal:prelude>:8:in `synchronize' /Users/tammam56/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service' /Users/tammam56/.rvm/rub...

[Ruby/Rails] How to execute code stored in DB?

Basically, I have an RPG-type Rails application. I'm storing skills in a skills database with the following fields: name, min_level, skill_type, formula My formula is stored as a String, currently. The idea is to have it say something like "1000*min_level" and somehow run it to calculate the skill damage. Is there any good way to do th...

Avoiding Duplicate Data in DB (for use with Rails)

I have five tables that I am trying to get to work nicely together but may need some help. I have three main tables: accounts members and roles. With two join tables account_members and account_member_roles. The accounts and members table are joined by account_members (fk account_id and member_id) table. The other 2 table...

How to update schema version manually in RoR?

I have a migration which adds triggers to MySQL via invoking ActiveRecord::Base.connection() method "execute". It works fine except what schema version is not updated. I suspect that is because the DB structure by itself is not changed (no columns and table updates). Is there a way to force the schema version update in my migration? ...

Specifying class name instead of id in Ajax on Rails

Hi friends, I need to know, how to fetch class name from div instead of id when using Ajax on Rails my coding is like below, <div id="test_test1" class="test"> </div> <div id="test_test2" class = "test"> </div> and on Controller, page.replace_html "test_test1", "<button>Thanks</button>" please help me to solve this problem. Th...

how to fetch values in self.find after using :from in rails

players_data = self.find(:all, :order => 'name', :conditions => 'p.country = c.id and p.position = po.id', :select => 'p.id as id, p.name as name, c.country as country, po.position as position, p.rank as rank', :from => 'players as p, countries as c, positions as po' ) -------------------------------- players_data.each do |ro...

How to display descriptive error message in ruby on rails

Hi, I have a problem in displaying the error message in Ruby on Rails. I' am using rescue => Exception ex #display ex.message the output I get when I tried to display it in an alert messagebox is this: "DBI::DatabaseError: 37000 (50000) [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot approve records for the specified...

prawn PDF: I need to generate nested tables

I need a table where rows are actually 2 rows tables, a nested table that is.. How can I do that in prawn? Maybe I need an extension.. but which one? ...

Vote_fu and Ajax requests

I've been at the for hours now, trying to get vote_fu and running. I have finally made a vote on a voteable object(album), but I have to keep refreshing the page to see the effect of my Ajax knowledge with rails is basic and I have no idea where I'm going wrong with this any help would be great would be much appreciated!!! The relevant ...

XML fetching and parsing solution/library that works with Ruby 1.9.1 on Rails 3

Does anyone know of a library that works with Ruby 1.9.1 on Rails 3 yet? Thanks, Nick ...

configuring .gems file (rails apps on Heroku)

Hi all, I'm learning how to deploy RoR (v2.3.4) on Heroku. Last night was my first attempt at pushing an app with an external gem (active_merchant). What is the URL format for configuring the .gems file? (My last attempt was 'active_merchant --source github.com/Shopify/active_merchant'.) Any inputs would be great. Thanks. -BrianP. (b...

Ruby String accent error: More than meet the eyes

I'm having a real trouble to get accents right, and I believe this may happen to most Latin languages, in my case, portuguese I have a string that come as parameter and I must get the first letter and upcase it! That should be trivial in ruby, but here is the catch: s1 = 'alow'; s1.size #=> 4 s2 = 'álow'; s2.size #=> 5 s1[0,1] #=> "a"...

Vestal_versions and acts_as_taggable_on

Hi, Does anybody successfully integrated vestal versions and acts_as_taggable_on plugins? I've added to my app, that using acts_as_taggable_on following line to environment.rb config.gem 'vestal_versions' and on any rake task or generator script call i see $ ./script/generate /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/...

Polymorphism on ActiveRecord model

I have two models, say Product and Bundle. products table is related to product_prices table and bundles to bundle_prices (need to make these separations to support multiple currencies) Obviously both Product and Bundle share some similar methods like get_price I have make both Product and Bundle pointing to an abstract Class for this...