ruby-on-rails

What's the best way to structure these relationships? To HABTM or not?

Just looking for some advice on how to structure my relationships in an app that I'm making. I have the following models: activity # golf, karaoke event # golf competition followed by all-night karaoke boat party post # write-up of the golf and karaoke event mentioned above gallery # photos from the golf and karaoke event Que...

Javascript saving xml using Ruby on Rails

Hello, First, what I am trying to do is: I am trying to create a browser application that works on clientside. The basic idea is the user uploads a xml file into javascript. Javascript does calculations on this data and displays results onto the browser. The user is able to interactively edit the result (something like an image/video) ...

Ruby Gem installation problem on Windows 7.

Hi there, I'm trying to install some Gems and need to run the following command: gem install mongrel mongrel_service mysql ruby-postgres oniguruma ultraviolet libxml-ruby --no-ri --no-rdoc --platform=mswin32 However, that --platform=mswin32 at the end of it bothers the hell out of me. I mean, my platform is x64 as it's supposed to b...

Rails, Mongrel and deprecation warnings

Hi all! When I do script/server I don't seem to get any deprecation warnings. I know that I should at least be getting one about {{word}} in I18N. Can anyone point out where I can find them? Or how I can enable the deprecation warnings? Regards, Jacob ...

Is it possible to do translation of YAML files content using ruby-gettext package?

I have a site which is currently implementing i18n using ruby-gettext package methods. All of the marked content within *.rb, *.erb, *.rhtml can all be translated and displayed correctly. But for lots of text stored in *.yml can't be displayed correctly although those marked strings have been inside of po files. Original yml file exampl...

Rails: How to disable a plugin from loading during startup

Hi, Is there anyway I can detect a exception and stop a plugin from loading in Rails? Thanks, Sivakumar. ...

returning an image with respond_to

How do I return an image inside the respond_to do |format| block? I already have the image fully assembled (i.e. no ugly assembling from blogs) and at a particular URL (because it's in the public folder), I just need to be able to return that image for a particular other URL query. For example, the image is in public/cars/userid/car...

Access to paperclip temp file when using s3 storage option on heroku

I am using the Paperclip gem to resize upload photos and store them on amazon S3. I need access to the resized photo to also pass along to another web service, during the lifecycle of the upload request. I suspect there is a temp file created somewhere the imagemagik uses before the photo is uploaded to s3. How can I get access to it....

Don't escape html in ruby on rails

Hello, rails 3 seems to escape everything, including html. I have tried using raw() but it still escapes html. Is there a workaround? This is my helper that I am using (/helpers/application_helper.rb): module ApplicationHelper def good_time(status = true) res = "" if status == true res << "Status is true, with a long ...

How do you add a timestamp URI to an image_tag in Rails?

Just like the title says : = image_tag @organization.logo.url(:cropped) I want this to appear as <img src="picture.jpg?23412341234" /> ...

Where should I put CONTROLLER helper methods?

I know that "helpers" are usually for views/templates. But say I have a helper method that I want to call from different controllers. Where should this file go? I was thinking of creating a helper module in the "models" folder but I'd like to know if there's a "correct" way to do this. ...

Test tableless model in Rails

When I run 'rake test' I get this error: 1) Error: test_the_truth(DetailsThankYouTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: details: DELETE FROM "details" WHERE 1=1 The application runs fine but I cannot write any simple test. How can I disable Rails test to use the table? ...

Toggle element by class name

I would like to toggle (hide/show) several elements of my web page. All those elements are in between this tag: <div class="class_name">to toggle</div> <div class="class_name">to toggle2</div> I would like to use javascript to toggle all the elements with class=class_name when the user clicks on a button. So far all the code I ...

How to upload a file in rails?

Hi, I'm new to rails. I want to know about file uploading process in rails. Can anyone please help me... Thanks, Althaf ...

Rails models: How to treat time constants correctly?

Hi there, I know the following model code is not correct: as models get loaded only on server boot, time "constants" are loaded at that time only, too. class Article < ActiveRecord::Base def expiring? if (self.enddate - Time.now) <= 1.day true else false end end end What do I have to correct how, so that...

Why does rspec redirect not get full route during test?

I'm attempting the following functional test on the controller. I'm using the following RSpec2 Rails 3 Shoudla Mocha Here's the test context "POST on create should be successful" do before(:each) do Model.any_instance.expects(:save).returns(true).once Model.any_instance.stubs(:id).returns(1) post :create, :model => {}...

Rails 3 UJS driver events

Hi, According to Simone Carletti blog post, Rails 3 ajax helpers have changed a lot. We are supposed to write more javascript with rails 3 than we used to with rails 2. I tried to figure out how to show up an ajax loading gif -while an ajax query is running- in the "rails 3 way". I came up with this kind of code, which uses javascript ...

rake spec cucumber complains about "no such file to load - ZenTest" despite ZenTest being installed

Hello! /home/soroush/.gem/ruby/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement no such file to load -- ZenTest /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/loca...

Error installing mysql2: Failed to build gem native extension.

Windowsxp. Ruby192. Rails installed. Mysql installed. When I try to run gem install mysql2 (or bundle install) I get errors: C:\ruby\cred2>gem install mysql2 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. C:/Ruby192/bin/ruby.exe extconf.rb ch...

is jquery-ujs all I need to use jquery with rails 3?

Will jquery-ujs give me all the helpers etc. that are used for all ajax helpers etc. that worked with prototype/script.? ...