ruby-on-rails

Rails template rendering slow?

i'm currently using mongrel server running rails2.3.5 with ruby1.8, and got this odd behavior: Rendered common/_header (3.1ms) Rendered common/_categories (1.2ms) Rendered common/_footer (1.2ms) Completed in 6934ms (View: 5897, DB: 174) ## 5897ms... to rendering a local page?? why? updated only one user there.. i'm working on my n...

Rails: Limit SQL fields for included table > find(:include => {:select => "id,title"})

I have 2 tables :products and :providers with has_and_belongs_to_many association. I would like to do this @list = Product.find( :select => "id,title", :include => { :providers => { :select => "id,title" } } ) How can specify fields for included table? Thx! ...

ruby on rails WIKI system plugin

hi all, this question is on ruby on rails technology. In my project we have the requirement to add wiki system. I want to know is there any plugin available which is best and readily available. i googled , got link on IRWI and others but not much useful. any answer would be appreciated. Mahesh ...

Spree how to use Hooks

According to http://spreecommerce.com/documentation/theming.html#hooks you should be able to use spree hooks using my_theme_hooks.rb but how? Do I need to extend a class and where can I check which hooks are used in the default theme? ...

jruby public database adapter

Hi I'm trying to deploy my rails application from jRuby to Heroku The db is giving me problems: $ heroku db:push Auto-detected local database: jdbcmysql://root:password@localhost/product_develo pment?encoding=utf8 Failed to connect to database: Sequel::AdapterNotFound -> Could not load jdbcmysql adapter: no such file to load -- /us...

How to set some field in model as readonly when a condition is met?

I have models like this: class Person has_many :phones ... end class Phone belongs_to :person end I want to forbid changing phones associated to person when some condition is met. Forbidden field is set to disabled in html form. When I added a custom validation to check it, it caused save error even when phone doesn't change. I...

Missing elements in an Ruby on Rails Array

Hi, i despair in case of an array. I put some data into an array, but when i iterate the array some elements of the array seems to be missed, but the missing element are displayed in the view. I'm using the Plugin Rails_Authorization. my Code: def index if !params[:task_id] #Tasks der 1. ebene anzeigen, auf die der User zugr...

How to apply named_scopes incrementally in Rails

named_scope :with_country, lambad { |country_id| ...} named_scope :with_language, lambad { |language_id| ...} named_scope :with_gender, lambad { |gender_id| ...} if params[:country_id] Event.with_country(params[:country_id]) elsif params[:langauge_id] Event.with_state(params[:language_id]) else ...... #so many combinations en...

Rails timezone ignored for ActiveRecord find?

I'm implementing the Timezone support in Rails 2.1+, and I've run into an apparent bug in the way the data is pulled from the db. Let me try to set it up. The "deals" model contains an "offer_date" datetime field. Let's say I have two records with these offer_dates: Deal 1: 2009-12-29 23:59:59 -0500 Deal 2: 2009-12-28 23:59:59 -0500 ...

Prototype, periodically_call_remote, updated content disappears when new link is clicked and lags.

Hi, periodically_call_remote is a great rails feature, but with ease comes novices so here I am. I have a div that is getting updated with content every 5 seconds. Looks great and was easy to setup. This page is the homepage so people will not be staying here long. So when they click another link, such as link_to "All Products", perio...

nested attributes and adding attributes through the controller?

As this question is hard to describe, that's the best title i could come up with, so here is some code. Given three Models Parent, Child && Grandchild. Parent < ActiveRecord::Base has_many :children has_many :grandchildren accepts_nested_attributes_for :child end Child < ActiveRecord::Base belongs_to :parent has_many :kids...

Is ActiveSupport::Cache::MemoryStore cleared up rails restart with Passenger?

I am pretty sure it does, but I wanted to double check, since I don't know exactly how Passenger restarts a rails app. So if I have something like: Rails.cache.fetch(:my_obj) { MyObj.first } will all the cache be cleared upon restart (which is my hope)? ...

Rails polymorphic associations, two assoc types in one class

Consider a class: class Link < ActiveRecord::Base has_many :link_votes, :as => :vote_subject, :class_name => 'Vote' has_many :spam_votes, :as => :vote_subject, :class_name => 'Vote' end The problem is, when I'm adding a new vote with @link.link_votes << Vote.new the vote_subject_type is 'Link', while I wish it could be 'link_vot...

Rails Fixtures not loading with rspec

So, I'm trying to learn the rspec BDD testing framework in the context of a rails project. The problem I'm having is that I can't, for the life of me, get my fixtures to load properly in rspec descriptions. Disclaimer: Yes, there are better things than fixtures to use. I'm trying to learn one thing at a time, here (specifically rspec)...

Best approach to pass hash type data in string form from Rails/Ruby to a C# app?

Hi, I need to pass (via string content of a HTTP request/response body) name value pairs of data (like a hash) back from a Ruby on Rails server to a C# client. Anyone happen to know offhand what would be the best format to do this in? Probably XML I would guess? tks PS. So overall the requirement is find a C# method that convert f...

File upload with the ability to resume (preferably in Ruby on Rails)

Hi all - this is quite a difficult topic by all accounts. I am building a website that requires users to upload large (multi-GB). What is the best way allow users to upload a file on a website and allow the file upload to be resumed should it fail? What is the way to write this in rails? Any ideas greatly appreciated. Max. ...

Nested routing for models with double associations

In a toy Rails application, I'm modelling a situation where you have a number of pots, each containing an amount of something, and you can make transactions between the pots. A transaction can come from any pot, and go to any pot. Here are the relevant parts of the models: class Pot < ActiveRecord::Base has_many :to_transactions, :f...

Installing Rails ERROR: could not find rails locally or in a repository

I've been poking around the internet looking for a solution on this one... with no luck.. I'm new to rails... If anyone has an idea, I'd love to hear it. Much appreciated! I enter: LW:src liamwright$ sudo gem install rails --include-dependencies And Get: INFO: `gem install -y` is now default and will be removed INFO: use --ignore-...

Multi-Model Forms with Image Upload

Hi, I'm trying to create a poll object which has many answers. Each answer can have an image attached. How can I create a form that allows me to enter the question and add a variable number of answers (each with their attached image). I'd also preferably want to allow preview of the images uploaded. My idea so far is to have a sub-form...

Cannot Run Ruby on Rails application from NetBeans IDE

I am trying to Run (F6) a Rails application from NetBeans 6.8 and when i do so I get the following output in the lower left hand status bar of the IDE: Could not connect to the web server - could not show http://localhost:3000 I don't believe that the WEbrick server is even starting, but i can start WEBrick and the same application ...