RailsCasts Pro episodes are now free!

Learn more or hide this

Alexandr Gajdosh's Profile

GitHub User: agm1988

Comments by Alexandr Gajdosh

Avatar

btw it happens only with the resources path like this. when I visit post views

ruby
resources :posts do
    resources :comments
  end
Avatar

Hi! I have the following problem: When I navigate across the site my locale changes to default. For Example when I am on index page and hit wookie and then go to another page my locale changes back to :en. I just can't get why?

my model is:
``` class Post < ActiveRecord::Base

attr_accessible :text, :title

translates :title, :text

validates :title, :presence => true,
:length => { :minimum => 5 }
has_many :comments, :dependent => :destroy

class Translation
attr_accessible :locale
end
end ```

And application controller
``` before_filter :set_locale

private

def set_locale
I18n.locale= params[:locale] if params[:locale].present?
end ```
Thanks in advice!

Avatar

I run in such problem, that i have a validation in task model of presence project_id,
Solution was: tasks.build(attributes.merge(:project_id => self), to merge attributes array with project_id.
I wonder is there a better solution to do this?
and why "tasks.build" in project model doesn't build this relation?
I am using Rails3, ruby 1.9.2

Avatar

I think to merge arrays of different model values

Avatar

I ran in to the following issue
with <%= f.collection_select :category_id, Category.find(:all), :id, :name, :prompt => "Select a Category" %>
we let user not to choose category_id, but use can also not type into create category field - so we let user to create product without category
if i add validation on cateory_id it did not save