Rails Dispatch

Rails news delivered fresh

Presented by Engine Yard

Recently asked questions

Vote on questions you’d like to see answered by the expert contributors

Signup to ask questions or vote for the questions you’d like to see answered.

Hi! I’m looking at the latest post on railsdispatch.com, which gives example code for a Rails 3 initializer, using the “Rails.application.configure” syntax. While I can’t find any good sources that refer to this directly, it looks like that syntax is invalid in recent releases of Rails (3.0-stable).

It’s hard to tell what version of rails was being used in the post, because the post simply says “more than a month ago”, and the only version information mentioned is “Rails 3”. In such a rapidly-changing world as the Rails APIs, a little more info, even just a note that the article is out of date, would be a huge help. Thanks!

Asked January 26, 2011

how can i work with parent child relationship multiple models one form

Asked February 12, 2011

Hi im quite beginner in rails. i have a problem suggestion will be appreciated.
i have two model “user” and “asset”
an “asset” is created by a “user” and asset" can be assigned to a “user” schema is
Asset { id,name,creator_id,assigned_to_id,price,…}
User{ id,name,….}
now in Asset model class association are
class Asset < ActiveRecord::Base
{
//validation
belongs_to :creator ,:class_name=>’User’
belongs_to :assigned_to, :class_name=>’User’ ,:foreign_key=>’assigned_to_id’
}

and User Model is

class User < ActiveRecord::Base
{
//any validation and other stuff
has_many :assets #did not specify either this accosiation #is for creator , or assigned to how can is specify this??
}

now in Asset show view i can obtain creator name with
@asset.creator.name

but can’t assigned_to name
@asset.assigned_to.name =>(error is )undefined method `first_name’ for nil:NilClas

and
@asset.assigned_to_id.name=>(error is) undefined method `first_name’ for 1:Fixnum

any suggestion how can i make double association with same model

}

}

Asked March 24, 2011

Hi im quite beginner in rails. i have a problem suggestion will be appreciated.
i have two model “user” and “asset”
an “asset” is created by a “user” and asset" can be assigned to a “user” schema is
Asset { id,name,creator_id,assigned_to_id,price,…}
User{ id,name,….}
now in Asset model class association are
class Asset < ActiveRecord::Base
{
//validation
belongs_to :creator ,:class_name=>’User’
belongs_to :assigned_to, :class_name=>’User’ ,:foreign_key=>’assigned_to_id’
}

and User Model is

class User < ActiveRecord::Base
{
//any validation and other stuff
has_many :assets #did not specify either this accosiation #is for creator , or assigned to how can is specify this??
}

now in Asset show view i can obtain creator name with
@asset.creator.name

but can’t assigned_to name
@asset.assigned_to.name =>(error is )undefined method `first_name’ for nil:NilClas

and
@asset.assigned_to_id.name=>(error is) undefined method `first_name’ for 1:Fixnum

any suggestion how can i make double association with same model

Asked March 24, 2011

Displaying the list of children as links under their respective parent:——

Hey…..Does nybody know how to display a list(array) as links
Eg: I’ve a @products and @categories enumerable objects supplied to the view from a single CategoryController …
I want to show the products under their respective categories as links and get rid of the separate show page for displaying products list…

I was able to get the categories links working as expected… but products name appear simply as plain text…..
<% @categories.each do |cat| >
<
= link_to( cat.name, cat) >
<
= cat.products.collect { |c| c.name } > ####<<< end %>
…But if I put link_to inside the cat.products.collect { |c| link_to c.name, c }, I get the html escaped text for links inside the[..]

Category and Product models have has_many_through relationship…

How to go about this……??????

Asked April 07, 2011

Hi There!

I’d be really interested in understanding how to structure a modular rails app with mostly shared model? I have a string need for control/view modules that depend on the same model.

Assume a CRM with a well structured and normalised DB as the the shared “Model”

Then there are web client view/controllers. admin view/controllers, api 1.0, api 2.0, mobile api, etc..

Any advice? Are engines the way to go or am I overthinking it?

Asked June 12, 2011

Hi

I need to create a single page spreadsheet web application in RAILS which should be exactly like google doc(should not use google docs API). It should have the following features

1) should scroll from row to row/ cell to cell using arrow keys and also want to copy and paste from cell to cell .

2)Adding , editing and deleting a record and it should contain sharing access for particular users .

3) If one user modifies the spreadsheet it should immediately reflect to all user who has permission to view that document.

3) overall it should be in a spreadsheet view.

If there is any other way to solve this solution means can u suggest me?? or please provide me a proper solution..

Thanks in Advance

Asked June 13, 2011

I plan to use Rails for a WEB application working with and existing Data Base (MySQL).
Unfortunately the DB does not comply with the default Rails rules (Table names, Primary Keyword, …) and it uses foreign keys.
Is it possible to customize the default Rails rules in order to comply with my DB definition ?
Thanks a lot in advance.
Massimo

Asked June 15, 2011

Hi,
I’m a great fan of website which talk about rails, like yours. It’s very nice of you and thanks for that.
I just have a short question about the tool you use to hightlight your code? I’ll need to use the same in my website :)
thanks a lot

Lionel

Asked August 17, 2011

hello,
i am new to ror,i wann to know how to make API call from one application to another. and also about API call

Asked September 10, 2011