ruby-on-rails

Why does DataMapper use mixins vs inheritance?

So I'm just curious about this: DataMapper uses a mixin for its Models class Post include DataMapper::Resource While active-record uses inheritance class Post < ActiveRecord::Base Does anyone know why DataMapper chose to do it that way (or why AR chose not to)? ...

rails layout not showing

I upgraded one of my apps from rails to 2.3.2 from 2.0.2. Start up find. However, once I start running any pages, the page will display but it doesn't seem to render any layout code. None of the standard tag such head, body which are in the layout get render. It seems that somehow layout is turned off. I checked the error log and did...

TimeWithZone comparison woes

>> t = Time.zone.now; a = Account.create(:last_result_at => t); a.reload.last_result_at == t => false >> t => Fri, 24 Jul 2009 21:52:16 UTC +00:00 >> a.last_result_at => Fri, 24 Jul 2009 21:52:16 UTC +00:00 What gives? ...

Rails eager loading of counts?

Eager loading is nice with the include attribute Post.find(:all, :include => :author) I'm wondering if you can also eager load counts, like if I wanted to get the number of comments for each post, without loading all the comments themselves? Maybe something like Post.find(:all, :include => [:author, "count(comments)") I suppose I ...

Why doesn't rake db:migrate report version number?

rake 0.8.7, rails/activerecord 2.3.3 Output from rake db:migrate: == CreateProducts: migrating ================================================= -- create_table(:products) -> 0.0017s == CreateProducts: migrated (0.0019s) ======================================== Shouldn't the version number, in this case 20090724013528, appear b...

Ruby on Rails - how to render as xml models with has_many associations

I have a ruby on rails application which has two models - ltests and sub_tests. An ltest has a 'has_many' association with sub_tests. In the show method for ltests is as follows. respond_to do |format| format.html # show.html.erb format.xml { render :xml => @ltest } end This renders the ltest object. However the sub_tests belongi...

Rails, searchlogic choose categories with checkboxes

Hello, I am useing searchlogic to search some paintings. Each painting belong to a single category. What I would like to do is add multiple checkboxes to my search form, so that users can mark multiple categories. (joined with or) Is this possible with searchlogic? The query I am looking for is something like this: SELECT * FROM painti...

Make link_to_remote Clickable Only Once

I am currently using link_to_remote in my Ruby on Rails app to render remote content using Prototype. Unfortunately if you click the created link more than once, it re-renders the content. What I would like to do is somehow disable the link after it is first clicked. This is the code I am currently using, <%= link_to_remote ( ...

Activerecord error .include? nil

I am writing a rails app, which has some modules and methods loaded via the lib directory, we have also added some methods in restful authentication module, now everytime when i run using mongrel server on production i dont get this error, although because model classes and controller classes are cached, but in development i do get this ...

View javascript generated by rjs file

The question is simple, yet I didn't find an answer to it yet: How can I view the javascript code generated by an rjs file? ...

How do I remove the Show/Hide links on a subgroup in ActiveScaffold?

With ActiveScaffold I have a group on my create form: config.create.columns.add_subgroup "Customer" do |customer_group| customer_group.add :customer_surname, :customer_postcode end This has a Show/Hide link which I don't want. How do I remove the Show/Hide links on a subgroup in ActiveScaffold? ...

Where are required gems defined?

In my rails application I once used authlogic-oid and ruby-openid. Now I want to get rid of them and I removed both gems and also their config.gem lines from my environment.rb. Although my application works, I can't do any database migrations because I get a "Missing these required gems" error. Also if I run rake gems:install these gem...

Setting up Paypal account in Substruct

Hi, I am new to both paypal and substruct. I trying to integrate paypal with 'Substruct'. The problem I am facing is that the payment status codes are not being updated in the admin panel. All of them are on Hold even when paypal sandbox successfully confirmed the orders. From the web somebody suggested that the 'notify_url' needs to be...

What's the best available open source editor/IDE for Ruby?

Possible Duplicate: What Ruby IDE do you prefer? I am purposing to use it for web development using Ruby on Rails. Any suggestions? And this is a CW ;) ...

printing a picture twice on the same page.

Hi, I want to enable printing a picture from my web page so that the picture will be previewed and printed twice on the same page i.e. 1 A4 with the image printed 2 or 4 times on the same A4. Is it possible with the FF and IE browsers interface? Thanks, Yuval. ...

Testing RESTful API with Cucumber in a front end less application.

Hi I do not have any front end in my app. I am willing to release just a RESTful API which can be used by different clients. Any pointers how should I proceed towards testing it with cucumber? Every action in the controller generates XML feed only. Any pointers or suggestions? ...

What are the benefits of using the Rails gem instead od vendor/rails?

I recently started working on a small personal project in Ruby on Rails, and have run into a few things that I couldn't find definitive answers for. If anyone here is knowledgeable enough to help, that would be greatly appreciated. All of my questions are below: What benefit is there to using the Rails Gem instead of having it in vend...

How do I securely store passwords in a configuration file in a Ruby/Rails web server environment?

I need to store payment gateway processor username/password credentials on a production web server, but would prefer not to do so in clear-text. What is the best way to store these credentials? Are their best practices for encrypting and decrypting this information? ...

How do I create a more meaningful error message in this case?

Say I have the following model: class Information < ActiveRecord::Base ... validates_length_of :name, :minimum=>3, :message=>"should be longer than 3 characters!" ... What I want to have as an error is: Information should be longer than 3 characters! (or similar) and NOT "Information name should be longer than 3 characters!". Two pos...

Distributing Rails Applications as Native Applications

I would like to distribute a rails application as a double clickable application. When someone double clicks on the app, I think that mongrel should be started and then the user's browser should be started and open to something like localhost:3000 I'm trying to work through what I will need to do this, I think I'm going to need to incl...