[Rails] What is Rails fixing versions in Gemfile?

2013-02-16 Thread Slava Vishnyakov
Hello, I'd like to ask why is Rails fixing it's version, like gem 'rails', '3.2.12' ? Given the recent attacks on Rails - wouldn't it be more secure to not fix the version? Maybe have something like '~>3.2.12' ? -- You received this message because you are subscribed to the Google Groups

[Rails] Rails3 ActiveRecord associations

2012-06-18 Thread slava
I have *Messages* and *User* models with corresponding tables. The *Messages* table has such fields like *user_from* and *user_to*. How can associate the models to be able to access sender and recipient users objects: message.user_from.name message.user_to.id ... Thanks. -- You received thi

[Rails] Facebook canvas app with rails3

2012-05-17 Thread Slava
I'm writing facebook canvas application with Rails3 using omniauth-facebook gem. The few moments are not clear: Rdirect after sing in (in '/auth/facebook/callback' => 'session#create'): After successful sing_in if user is redirected to root_url it sometime arrives to my canvas page URL (ht

[Rails] Re: Is Rails on IIS dead?

2011-12-27 Thread Slava Shynkarenko
John Maxwell wrote in post #1037800: > This seems like a cruel joke to have to constrain RoR, or any modern web > framework to IIS. If your company are concerned about rails > implementations not being "enterprise" enough, then JRuby comes to the > rescue - coupling the ease of rails with the enter

[Rails] translation missing: en.date.formats.default

2011-11-26 Thread slava
Getting a strange error on missing translation. >>I18n.l(Order.first.created_at.to_date) I18n::MissingTranslationData: translation missing: en.date.formats.default But if try this: I18n.l(Order.first.created_at) "2011-11-26 13:25:21 UTC" this is in my config/locale/en.yml en: date: form

[Rails] url helper in model.js.erb.cofee (Sprockets::Context)

2011-11-09 Thread slava
hello, I am writing a js/coffee file that gets erb handling and I need to use a url helper inside this file if write .. url: '<%= url_for(:action => :index) %>' I get an error: NoMethodError Exception: undefined method `url_for' for #<#:0xeed1eb8> >>self.class # < Sprockets::Context How do

Re: [Rails] undefined method `seed'

2011-11-09 Thread Slava Mikerin
quot;Rameshwar Vyevhare" > wrote: > >>Pls try out this  heroku:rake:db:seed >> >>On 08/11/11 3:16 AM, "slava" wrote: >> >>>hello, >>>I am trying to deploy a rails 3.1 app to Heroku and need to run >>>db:seed >>>My

Re: [Rails] undefined method `seed'

2011-11-09 Thread Slava Mikerin
heroku:rake:db:seed command does not exist. Are you sure about this sintax? On Tue, Nov 8, 2011 at 9:06 PM, Rameshwar Vyevhare wrote: > Pls try out this  heroku:rake:db:seed > > On 08/11/11 3:16 AM, "slava" wrote: > >>hello, >>I am trying to deploy a rails

[Rails] undefined method `seed'

2011-11-07 Thread slava
hello, I am trying to deploy a rails 3.1 app to Heroku and need to run db:seed My seeds file has this code User.seed do |s| s.email = "t...@temp.com" s.password = "bigsecret" s.password_confirmation = "bigsecret" end Running rake db:seed locally works fine, but after deployment to Heroku I

[Rails] Re: scopes related question

2011-10-13 Thread slava
figured out the answer to this problem. I needed to use :joins to include associated models in scopes. On Oct 11, 10:05 pm, slava wrote: > Hello, > Have a question related scope definition. I need to define a scope > based on related model attribute values like this. > >

[Rails] `require': no such file to load -- rspec/rails (LoadError)

2011-10-12 Thread slava
Getting strange loading problem.. >> bundle exec rspec -p spec/models/* give error: .. .rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/ dependencies.rb:240:in `require': no such file to load -- rspec/rails (LoadError) from /home/slava/.rvm/gems/ruby-1.9.

[Rails] scopes related question

2011-10-11 Thread slava
Hello, Have a question related scope definition. I need to define a scope based on related model attribute values like this. class Product < ActiveRecord::Base belongs_to :currency scope :with_currency, lambda { |currency| unless currency.to_s.upcase == 'ALL' # here I need to define a sco

[Rails] inflections problem - rails 3.1.1

2011-10-09 Thread slava
After upgrading to Rails 3.1.1 I am getting an error related to inflections for a model - TradeTerms This model has same name for singular and plural tenses, but this is now not recognized and I get error: uninitialized constant TradeTerm I tried messing around with initializer for inflections and

[Rails] Re: better looking routes

2011-09-25 Thread slava
Great. Just what I was looking for. Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr..

[Rails] better looking routes

2011-09-25 Thread slava
Hello, I am trying to replace default restful routes for a few of my models to something that looks a bit better. resources :countries gives /countries/:id should be replaced with /countires/:country_name Any ideas on how this could be done? thanks. -- You received this message because you ar

[Rails] routing question

2011-09-19 Thread slava
Hello, I wonder how to tell my routes.rb to route requests to a resource to it's parent controller class Foo < Bar end resources :foos ===> controller :bars -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send e

[Rails] modifying parent's validator in child model

2011-09-14 Thread slava
Hello, I need to remove a validator from a parent model in a child model. Tried _validators.delete, but that does not seem to work and validation on parent class is still called. class Order < ActiveRecord::Base validate :has_available_shipment end class TradeOrder < Order # tried this from s

[Rails] Re: singleton active record

2011-09-05 Thread slava
Found the answer. thanks. I had to install gem "acts_as_singleton" -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rub

[Rails] singleton active record

2011-09-05 Thread slava
hello, I am trying to define a singleton active record on a rails 3.1 app. What's missing please? class Bitcoin < Currency include ActiveRecord::Singleton end When I run Bitcoin.instance get this error: NameError: uninitialized constant ActiveRecord::Singleton -- You received this message b

[Rails] advanced scopes

2011-09-05 Thread slava
hello, I am trying to wright a scope with something like this.. class User < ActiveRecord::Base has_many :balances, :dependent => :destroy scope :with_positive_balance, where(balances.amount > 0) end What is the correct format for this type of scope? Thanks. -- You received this message be

[Rails] basic http authentication

2011-08-20 Thread slava
Hi, I used code from http://railscasts.com/episodes/82-http-basic-authentication but added it to Application controller to apply to the whole application class ApplicationController < ActionController::Base protect_from_forgery before_filter :authenticate protected def authenticate pu

[Rails] rendering absolute paths by default

2011-03-09 Thread slava
Hello, Is there any setting to make all urls render full address as opposed to relative by default? so call to: users_path -> http:localhost:3000/users as opposed to / users thanks, Slava -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Tal

[Rails] " instead of " in js code rendered by erb

2011-03-08 Thread slava
Having problems rendering javascript in erb file. Thanks for suggestions. //layout erb file (function() { ... var widget_properties = {}; <%= content_for?(:extend_widget) ? "widget_properties = " + yield(:extend_widget) : '' %> ... })(); //view erb file <% content_for :extend_widget do %

[Rails] routing error for a nested controller and rspec

2011-02-09 Thread slava
Hello, I am getting a strange error when using rspec with nested routes it 'succeeds' do get :index, @parameters response.should be_success end ... Failure/Error: get :index, @parameters ActionController::RoutingError: No route matches {:website=>#http://somewebsi

[Rails] Re: has_many :through question

2011-02-07 Thread slava
found the problem :) had to change WebsiteUser's has_many :marks to include :foreign_key => author_id class WebsiteUser < ActiveRecord::Base has_many :marks, :foreign_key => :author_id has_many :videos_marked, :through => :marks, :source => :markable, :source_type => "Video", :class_name => "

[Rails] has_many :through question

2011-02-06 Thread slava
Hi, I am having some difficulty getting has_many relationship setup correctly. def acts_as_markable has_many :marks, :as => :markable belongs_to :author, :class_name => "WebsiteUser" end class Video < ActiveRecord::Base set_table_name "markables" acts_as_markable e

Re: [Rails] how to set default_scope for the whole application?

2011-02-02 Thread Slava Mikerin
in what file do I put this or similar code? On Wed, Feb 2, 2011 at 11:00 AM, Slava Mikerin wrote: > I want is to set > default_scope :order => 'created_at ASC' > for all models on default. How is that done? > > > On Wed, Feb 2, 2011 at 6:23 AM, Walter Lee Davis

Re: [Rails] how to set default_scope for the whole application?

2011-02-02 Thread Slava Mikerin
g Controller-wise > inherits from ApplicationController, and what about controllers that don't > just manage one model? This sort of thing has got to end badly is my guess. > > Walter > > > On Feb 1, 2011, at 10:15 PM, slava wrote: > > I know I can set default_sc

[Rails] how to set default_scope for the whole application?

2011-02-01 Thread slava
I know I can set default_scope for individual active record model, but can I set one up for the whole application? thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.

[Rails] How to apply an application template on an existing Rails 3 app?

2010-08-04 Thread slava
Hello, I want to run a template on an a Rails 3 app after it has already been created. Is there a command for that? thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups

[Rails] redirect fails..

2009-10-26 Thread slava
hello, I am testing an ActiveResource model create method. The remote service is sending back a redirect request with newly created record url, but for some reason redirection fails and I get 1) Error: test_should_create_a_sales_quotation(SalesQuotationsControllerTest): ActiveResource::Redirectio

[Rails] Re: filter activeresource response body

2009-09-28 Thread Slava Mikerin
found a way :) had to overwrite instantiate_record method inside ActiveResource. On Sun, Sep 27, 2009 at 11:57 PM, slava wrote: > Hello, > I have an ActiveResource model that loads imperfectly structured json > from a third party service. I need to catch response before its parsed

[Rails] filter activeresource response body

2009-09-27 Thread slava
Hello, I have an ActiveResource model that loads imperfectly structured json from a third party service. I need to catch response before its parsed by the model and make a few corrections on the json. How should I go about doing this? thanks, Slava

[Rails] active_record has_many, :through and active _resource

2009-08-25 Thread slava
Hello, I have many to many relationship between Venue and Catalog class Venue < ActiveRecord::Base has_many :venue_catalogs has_many :catalogs, :through => :venue_catalogs end class VenueCatalog < ActiveRecord::Base belongs_to :venue belongs_to :catalog end class Catalog < ActiveResourc

[Rails] ActiveResource and inheritance

2009-08-07 Thread slava
Quotation < Document < ActiveResource doc = Document.find(id) # GET http://someurl/documents/.xml # # ... # doc.class # => Document instantiates Document even when the record is a Quotation How do get the doc to be instantiated as Quotation? than

[Rails] Re: ActiveResource xml element ordering

2009-08-04 Thread Slava Mikerin
ok. I found solution :) Here is what I did class SalesDocument < ActiveResource::Base def encode builder = Builder::XmlMarkup.new(:indent=>2) builder.instruct! builder.tag!('sales-document'){ builder.items('type' => 'array'){ self.items.each do |item| builder

[Rails] Re: ActiveResource xml element ordering

2009-08-04 Thread Slava Mikerin
I am stuck.. here is what i tried class SalesDocument < ActiveResource::Base def encode SalesDocumentsController.new.render_to_string :template, 'rxml-file' end end But that does not work. I get: NoMethodError: protected method `render_to_string' called for # -- Posted via http://www.r

[Rails] Re: ActiveResource xml element ordering

2009-08-03 Thread Slava Mikerin
10:56 PM, Slava > Mikerin wrote: > >> I am using ActiveResource to integrate with a 3rd party service. >> when calling MyModel.save a POST with xml is sent. >> I need to make sure that xml is created with defined order of >> elements (the service requires it)

[Rails] ActiveResource xml element ordering

2009-08-03 Thread Slava Mikerin
Hello, I am using ActiveResource to integrate with a 3rd party service. when calling MyModel.save a POST with xml is sent. I need to make sure that xml is created with defined order of elements (the service requires it) How can I do that? Some have suggested using rxml or builder, but I am not su

[Rails] Re: ActiveResource xml element ordering

2009-08-01 Thread slava
SalesDocument < ActiveResource I need to make sure that when I call SalesDocument.save the order of elements in the xml is predetermined and consistent, which currently not the case. POST http:///sales_documents.xml body: 3.0 AD_DASHERBOARD-200 110 10 110

[Rails] ActiveResource xml element ordering

2009-07-31 Thread slava
Hello, I am using ActiveResource to integrate with a 3rd party service. when calling MyModel.save a POST with xml is sent. I need to make sure that xml is created with defined order of elements. How can I do that? Some have suggested using rxml or builder, but I am not sure how. Has anyone done th

[Rails] Re: has_many :through habtm

2009-07-10 Thread slava
yeah, I think it is sufficient. thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this grou

[Rails] has_many :through habtm

2009-07-09 Thread slava
Here is my setup: class Product < ActiveRecord::Base belongs_to :catalog has_and_belongs_to_many :product_groups end class ProductGroup < ActiveRecord::Base belongs_to :catalog has_and_belongs_to_many :products end class Catalog < ActiveRecord::Base has_many :product_groups has_many

[Rails] Re: search in scaffold

2009-07-03 Thread slava
Take a look at active scaffold http://wiki.github.com/activescaffold/active_scaffold On Jul 3, 12:18 am, beny 18241 wrote: > Hi > > Anyone knows how to put search option in scaffold? > > Reagrds > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~

[Rails] modules and models

2009-07-02 Thread slava
Hi, I am trying to namespace my models in a Rails app. I put this in routes map.namespace(:property) do |property| property.root :controller => :venues, :active_scaffold => true property.resources :location_groups, :active_scaffold => true end and this in app/controllers/p

[Rails] sap4rails

2009-06-12 Thread slava
Hello, I need to integrate my Rails app with SAP back-end. I found this library sap4rails, which apperenty is meant to help, but I see that the library has not been modified since 07, and wonder if it is up-to- date. http://raa.ruby-lang.org/project/sap4rails Does anyone have experience working

[Rails] Re: distributed models

2009-06-12 Thread slava
is up-to-date. I wonder if anyone has worked with sap4rails and if it is a good solution for integrating with SAP back-end. thanks, Slava --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk"

[Rails] distributed models

2009-06-11 Thread slava
the questions I have to find answers to are: - How does one use ActiveRecord with shared models? - What are the implications of this type of distributed design? - Relevant design patterns. thank you, Slava --~--~-~--~~~---~--~~ You received this message because you

[Rails] distributed models

2009-06-08 Thread slava
questions I have to find answers to are: - How does one use ActiveRecord with shared models? - What are the implications of this type of distributed design? - Relevant design patterns. thank you, Slava --~--~-~--~~~---~--~~ You received this message because you are

[Rails] booting rails

2009-05-06 Thread slava
I need to use an activerecord model in a ruby script that is run from outside rails, so I need to boot rails from my script, otherwise I get uninitialized constant ActiveRecord I tried adding require 'config/boot' to the script to boot rails before running the script, but that did not help.. --~--

[Rails] find_by...

2009-04-29 Thread slava
Hello, I am trying to construct a lookup based on params submited. possible urls.. /gadgets?product_id=1 /gadgets?product_id=1&product_group_id=2 /gadgets?product_location_id=5 /gadgets?product_id=1&product_location=5 ... How do I write a universal lookup method ? Gadget.find_by_product_id Gadge

[Rails] Re: ActiveRecord and :include

2009-04-14 Thread slava
thanks, I ended up doing this. format.json { render :json => @product_locations.to_json (:include => :product_location_mappings)} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To

[Rails] ActiveRecord and :include

2009-04-14 Thread slava
here is my model class ProductLocation < ActiveRecord::Base belongs_to :property has_many :product_location_mappings end I want to load product_locations along with referenced :product_location_mappings and return a deep model. @product_locations = ProductLocation.find_all_by_property_

[Rails] Re: create_table with unique combo

2009-04-08 Thread slava
on the same subject.. I need to ensure uniqness of name in a table. I tried setting collumn to unique (see below) but that did not work. I still can create records with same name field. create_table :properties do |t| t.string :name, :unique => true t.string :description t.t

[Rails] Re: create_table with unique combo

2009-04-08 Thread slava
alternatively if i leave default integer id as primary key I need to make sure combo of name and version are unique. create_table :catalogs do |t| t.string :name t.string :version, :default => '01' t.timestamps end --~--~-~--~~~---~--~~ Y

[Rails] create_table with unique combo

2009-04-08 Thread slava
I need to create a table replacing default integer id with a string id and making a combo of (id and version) unique primary key. Here is what I've got so far. class CreateCatalogs < ActiveRecord::Migration def self.up create_table :catalogs, :id => false do |t| t.string :id, :limit =

[Rails] Re: ActiveRecord and SOAP

2009-03-18 Thread slava
erick Cheung wrote: > On Mar 18, 8:42 pm, slava wrote: > > > I need to get some of the data for my models from SOAP based services > > and some from a rails db. I am relatively new to Rails and not sure > > how to do it right. > > > class Product < ActiveR

[Rails] ActiveRecord and SOAP

2009-03-18 Thread slava
I need to get some of the data for my models from SOAP based services and some from a rails db. I am relatively new to Rails and not sure how to do it right. class Product < ActiveRecord::Base # products should be loaded through a soap service from a 3rd party system belongs_to :product_group