[Rails] Re: Re: validate sub models in parent model?

2011-01-02 Thread Michal Burak
>> So you are just wanting uniqueness of www_link.href? Will not >> validates_uniqueness_of in WwwLink class (backed up by a unique >> constraint in the database of course) do the job? I think in this >> case it will be the foo2.www_links.create that will fail. >> Colin > The constraint is on "ow

[Rails] Re: Re: validate sub models in parent model?

2011-01-02 Thread Michal Burak
Colin Law wrote in post #971847: > On 2 January 2011 14:11, Michal Burak wrote: >>>> >> link1.save! >> >> foo2 = create_foo.save! >> link2 = foo2.www_links.create(:href => 'wp.pl') >> >> # when >> link2.save! >> >

[Rails] Re: validate sub models in parent model?

2011-01-02 Thread Michal Burak
Colin Law wrote in post #971843: > On 2 January 2011 13:42, Michal Burak wrote: >> class Foo < ActiveRecoed::Base >> has_many :www_links, :as => :owner >> end >> >> class WwwLink < ActiveRecord::Base >> belongs_to :owner, :polymorphic => true >

[Rails] validate sub models in parent model?

2011-01-02 Thread Michal Burak
class Foo < ActiveRecoed::Base has_many :www_links, :as => :owner end class WwwLink < ActiveRecord::Base belongs_to :owner, :polymorphic => true attr_accessible :href end I want to ensure that each Foo instance does not have same links (href). My first attempt would be to write validation

[Rails] Re: Request for comment on post on SEO QuickStart for Rails

2010-12-28 Thread Michal Burak
Thanks a lot guys! This is a piece of useful info :) -- Posted via http://www.ruby-forum.com/. -- 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.com. To unsubscribe from t

[Rails] Request for comment on post on SEO QuickStart for Rails

2010-12-21 Thread Michal Burak
Hi, http://programmers-blog.com/2010/12/21/quick-start-to-seo-for-ruby-on-rails What do you think about this guys? I looked through the whole Internet ;) and found nothing simple that would suit my simple needs. So I did these things on my own and wrote about the process. Thanks for any comment

[Rails] Re: rails console and tests launch time too long?

2010-10-17 Thread Michal Burak
The speed is the same with or without RadRails. -- Posted via http://www.ruby-forum.com/. -- 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.com. To unsubscribe from this g

[Rails] rails console and tests launch time too long?

2010-10-16 Thread Michal Burak
When I run script/console I have to wait like 10 seconds to the console to start. When I run any of the tests in my rails app ('rake test' or whatever else like AltShiftX+U in RadRaild) I also have to wait about 7-10 seconds for the testing itself to start. This slows down my continues-developmen

[Rails] Re: tips on how to write a controller test for models associ

2010-04-21 Thread Michal Burak
Kura Monni wrote: > current_user is defined in the ApplicationController class and it's set > as a helper_method, but apparently it's still not visible in the Webrat > steps. Check this out http://programmers-blog.com/2010/04/21/cucumber-vs-webrat-vs-current_user-from-authenticatedsystem PS. S

[Rails] as_json for arrays?

2010-03-06 Thread Michal Burak
Hi. The file /rails/activesupport/lib/active_support/json/encoders/enumerable.rb Has: class Array (...) def as_json(options = nil) #:nodoc: self end end I want a as_json method FooModel.all.as_json(:only => [...]) that will work same as FooModel.first.as_json(:only => [...]). I had t

[Rails] model associations and optimization problem

2010-03-01 Thread Michal Burak
Hi. Any way to write this more efficiently? Can I make the active record handle this through some kind of association? @images = [] current_user.foo_models.each do |foo| @images.concat(foo.images) end Any help appreciated. -- Posted via http://www.ruby-forum.com/. -- You re

[Rails] current selected menu element?

2010-01-06 Thread Michal Burak
Hi, I am using rails 2.3.4.. Any idea how to implement such thing?: def secondary_menu_link_to(link_name, link_path) if (link_path is the current @controller.controller_path and @controller.action_name) link_to "&racuo; #{link_name}", link_path else link_to link_name, link_

[Rails] Re: integrations tests questions

2009-11-09 Thread Michal Burak
Marnen Laibow-Koser wrote: > In my opinion, integration tests are a bit clumsy. Cucumber features > will be easier to work with, and will also address the issues you were > asking about. > >> >> Thanks in advance. >> >> M. Looks nice, I'll check it deeper. Thanks. My fiend found another si

[Rails] Re: integrations tests questions

2009-11-09 Thread Michal Burak
Ok, I have the answer figured out for the quesion "how to specify ID": assert_redirected_to '/my_models/edit_photos/' + assigns(:my_model).id.to_s But I still dont know how to avoid hardcoded paths. I want to replace: get '/foo/bar' with something like: get :controller => :foo, :action =>

[Rails] Re: dynamic collection_select

2009-11-09 Thread Michal Burak
I think you need AJAX here to populate the cascade "rest of the drop downs" or refresh the whole page on change of the first drop down and feed the collection_seelct in the controller with appropriate data. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~

[Rails] integrations tests questions

2009-11-09 Thread Michal Burak
Hi, --- ROUTING --- I have roting defined as RESTful but for the below testes MyModels controller I have a standard map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' SAMPLE TEST -- class MyIntegrationTest < ActionController::IntegrationTest fixt

[Rails] Re: Plugin not instaling?

2009-11-02 Thread Michal Burak
Ok, it is working, change git:// to http:// and add a trailing / to the URL. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this gr

[Rails] Re: Plugin not instaling?

2009-11-02 Thread Michal Burak
I tried this, but its still not doing everything: woj...@wojtek-laptop-hp:~/workspace_galileo/miejscowki$ ruby script/plugin install http://github.com/ewildgoose/render_component.git/ -r rails-2.3 + ./README + ./Rakefile + ./init.rb + ./lib/components.rb + ./test/abstract_unit.rb + ./test/compo

[Rails] Plugin not instaling?

2009-11-02 Thread Michal Burak
Hi. I try to install a plugin, but with no success, nothing is printed, the plugin is not installed. Input and output on my console: woj...@wojtek-laptop-hp:~/workspace_galileo/miejscowki$ script/plugin install git://github.com/ewildgoose/render_component.git -r rails-2.3 woj...@wojtek-laptop-hp

[Rails] calling partials from a layout - once nil, once not nil

2009-09-25 Thread Michal Burak
Hi, Rails 2.3.3 + restful_authentication. current_user is a method from lib/authenticated_system.rb through "include AuthenticatedSystem" in application_controller.rb home/_current_user.pl.html.erb : <% if current_user %> NOT NIL <% else %> NIL <% end %> home/

[Rails] Re: using jQuery for remote_for

2009-07-11 Thread Michal Burak
http://docs.jquery.com/Using_jQuery_with_Other_Libraries I sometimes use this, this is a litle bit of topic but it may help sometimes. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goo

[Rails] offeride :limit named_scope default_scope

2009-07-11 Thread Michal Burak
Hi, Rails 2.3.2 class TestD < ActiveRecord::Base default_scope :limit => 12 named_scope :limit, lambda { |num| { :limit => num} } end ruby script/console >> TestD.all TestD Load (0.7ms) SELECT * FROM "test_ds" LIMIT 12 => [] >> TestD.limit(14) TestD Load (0.3ms) SELECT * FROM "test

[Rails] Re: paperclip unit testing

2009-07-07 Thread Michal Burak
Thanks! How do you process the image in the model? Before the save of the model object to database I want to add another image to it, that is a modified version of the "image" attribute. I do: has_attached_file :image has_attached_file :image2 after_validation :prepare_image2 And: def

[Rails] paperclip unit testing

2009-07-07 Thread Michal Burak
Hi, Rails 2.3.2, paperclip 2.2.9.2 How can I unit test my model that has a paperclip attachment? I add to my model: --- CODE START --- has_attached_file :image, :default_url => '' attr_protected :image_file_name, :image_content_type, :image_image_size --- CODE END --- Than I type a UNIT test:

[Rails] has_many relationship - specify how quantity (how many)

2009-07-05 Thread Michal Burak
Hi, Is there any way to specify a a validation rule or something for the "has_many' relationship so that it would count the related objects? For e.g. I want my Foo object to have maximum of 5 Bar objects in has_many relationship. M. -- Posted via http://www.ruby-forum.com/. --~--~-~--

[Rails] Re: rcov plugin overwrites its results?

2009-06-06 Thread Michal Burak
Fernando Perez wrote: > > I personally type: rake test:coverage and it works fine. I have no such task. You probably use http://clarkware.com/cgi/blosxom/2007/01/05/RcovRakeTask But this generates separate coverage results for each test bundle. I want a overall one. M. -- Posted via http://w

[Rails] Re: rcov plugin overwrites its results?

2009-06-05 Thread Michal Burak
My friend found a workaround solution. If anybody is interested its posted here http://programmers-blog.com/2009/06/05/rconv-rails-rake-task-test-test-rcov-overwrites-its-output M. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this

[Rails] rcov plugin overwrites its results?

2009-06-04 Thread Michal Burak
Hi, rake test:test:rcov This outputs to my console proper results. All test are run and coverage percentage differs when running functional/integration/unit tests. But at the and I get only one folder "coverage/test" with the last results in HTML format. The logs of the plugin say (3 times): (

[Rails] Re: override finders?

2009-06-01 Thread Michal Burak
MaurĂ­cio Linhares wrote: > http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-default-scoping Thats it! Thanks! M. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

[Rails] override finders?

2009-06-01 Thread Michal Burak
Hi, 1. I have my model for e.g. "Car". I used this model in lots of places. 2. In a migration I added Car.is_visible default => false. 3. Now I wan all of the finder methods to take this flag under consideration. So initaly none of the Cars will be displayed on my site. I will have to look for

[Rails] assert method is not visible?

2009-05-29 Thread Michal Burak
Hi, test "is_admin method is not visible" do get :is_admin assert_??? end is_admin is protected and should stay that way forever. What assertion do I use? M. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this messa

[Rails] Re: attachment_fu and rails 2.3.2 no image on disk

2009-05-28 Thread Michal Burak
> > LOL what's the permission policy? > > Whichever user is running the app needs write access if you want to > write files, unless I'm seriously mistaken. > > Julian. Whatever, I don't know what could it mean. I'm not that familiar with rails unfortunately. The problem is that after migrati

[Rails] Re: attachment_fu and rails 2.3.2 no image on disk

2009-05-28 Thread Michal Burak
The problem is probably something similar to http://blog.methodmissing.com/2008/1/19/edge-callback-refactorings-attachment_fu/ In my case the method process_attachment defined as a after_validation callback doesn't get called for the second attachment of my model. I replaced beginning of the me

[Rails] Re: attachment_fu and rails 2.3.2 no image on disk

2009-05-27 Thread Michal Burak
Julian Leviston wrote: > His problem is most likely a permissions issue. > Did the "permission policy" between rails 2.1 and 2.3 change? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the G

[Rails] attachment_fu and rails 2.3.2 no image on disk

2009-05-27 Thread Michal Burak
Hi, After upgrade to Rails 2.3.2 I have a problem with attachments. After uploading the attachment in the images table there is a new record. But the file does not exist on the file system. has_attachment :content_type => :image, :storage => :file_system, :size =