[Rails] Re: difference between in_groups and in_groups_of Rails
On Saturday, November 1, 2014 8:41:12 PM UTC, Arup Rakshit wrote: Hi, I am not finding any difference between the 2 methods - in_groups and in_groups_of. Is their really any difference between in_groups and in_groups_of.. http://api.rubyonrails.org/classes/Array.html#method-i-in_groups. in_groups_of(n) returns/iterates over groups that are all of size n (except possibly the last), and the number of groups is length/n (rounded upwards) in_groups(n) on the other hand returns exactly n groups, with the size of the groups being length/n (if length is a multiple n, if not depends on whether you asked for padding. For example [1,2,3,5,6,7,8,9,10,11,12].in_groups_of(2) #= [[1,2],[3,4], [5,6], [7,8], [9,10], [11,12]] - you've asked for groups of size 2 [1,2,3,5,6,7,8,9,10,11,12].in_groups(2) #= [[1,2, 3,4, 5,6], [7,8, 9,10, 11,12]] - you've asked for 2 groups Fred -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d096e494-3928-4854-b363-4b31b7ca10d1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Difference between Cookies and Sessions
Praveen BK wrote in post #1151760: Hello, Can anybody please define cookies and sessions and their differences in detail with reference to rails. What may be confusing you, that I've not seen mentioned yet, is that session identifiers are stored in cookies. Let me explain by looking at the process... Actors: - User Agent (Web Browser) - Local storage (Cookies, Local Storage, etc.) - User (Person using User Agent) - Application (Server side Rails, PHP, ect.) 1. User enters URL into address bar of User Agent (e.g. http://example.com/). 2. User agent looks up cookies in Local Storage matching domain (e.g. example.com). 3. User agent sends request, with attached cookies, to Application. 4. Application parses incoming request, extracting any cookies found in request. 5. Application searches for session cookie. Goto to #7 if found. 6. Application creates new session cookie if necessary 7. Application renders response. 8. Application attaches all cookies to response. 9. Application send response to User Agent. 10. User Agent extracts cookies from response. 11. User Agent stores cookies from response in Local Storage. Noticed #6 says if necessary. It's possible to have session-less requests (i.e session only on demand) As you can see the session cookie is a cookie like any other. It is nothing more than an opaque identifier used to track a User between requests. Requests in HTTP are stateless, there is no way to know that two requests are really part of the same Application session. The concept of session is at the application layer and not at the protocol layer (HTTP), which has no notion of application session. To work around the stateless nature of HTTP we use cookies in order to emulate state. Session cookies are cookies, but not all cookies are session cookies. Sometimes you just want to store arbitrary data in the User Agent's Local Storage, and have the User Agent send it back to you on subsequent requests. Session cookies are not to be confused with Rails's cookie based session storage. This is also implemented using a cookie, and is separate from the session identifier cookie. Session storage cookies, of course, have the same limitations as any other cookie (because they ARE just a cookie). The limitation of the most concern is the 4K size limit. You cannot store more that 4K (total) for each Rails session, including the overhead info Rails puts in the session storage cookie. Normally this is not a problem since you want to minimize the amount information you store in a session. A common item for session storage is the User, so that you can match a specific session to a specific user of your application. It is important to understand that there is no need to store the entire User model in the session. All you need to store is the id of the User model so that you can lookup the actual User model on each request. (Example: session['user_id] = some_user.id NOT session[user] = some_user) Hope this helps clear thing up for you. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6ebf37cfe2d10b1c4f2f17bd9e898c20%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Difference between _path and :action = 'some_method'
On Monday, March 18, 2013 8:33:15 AM UTC, Barry wrote: Hello. So solved some error with just replacing path method with calling :action=... But I'm curious why in absolutely same in first case _path worked perfect, in second it causer an error which is solved just by changing syntax (but not the sence of what is happening) First case: %= form_for @answer, {:url = create_answer_test_path(@test), :html = {:id=form_#{@key.position}}, :remote=true} worked with no problem %= button_to '-', {:url=delete_answer_test_path(@test)}, :method=:delete, :remote =true % Caused several types of errors: ActionController::RoutingError (No route matches {:action=delete_answer, :controller=tests, :id=nil}) You haven't said what the route is, but it would appear that you've made it a member route of a collection: this is an action that does something with a specific instance of your Test class. What this error is saying is that @test is apparently unsaved so doesn't have an id, which doesn't make any sense to rails (although of course it doesn't know if you then use the id parameter or not) Fred -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/j3ol6ogOJqAJ. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: Difference between save and create ?
thanks a lot. -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: difference between build_ and .build
LED wrote in post #1053782: hi im new in Ruby on rails and currently working with a reservation system can anyone explain what is the difference between current_package = build_reservation_package(:package_id = package_id) abd current_package =reservation_package.build(:package_id = package_id) because i tried using the first one but no good but when i try the second it worked i think both are the same please correct me if im wrong thank I understand the difference between the two builds as follows: I am assuming you are using nested_attributes and if so then my understanding is that in your controller you will be building the reservation_package object so that your form has something to work with. If you have a has_many association then your controller will use the reservation_packages.build option and if you are working with a belongs_to association then you will find that the build_reservation_package is what is called for. I am new to rails as well, but that is what I have gleaned so far ... hope it helps. -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: difference between build_ and .build
On Wed, Mar 28, 2012 at 8:41 PM, Tom Tom li...@ruby-forum.com wrote: LED wrote in post #1053782: hi im new in Ruby on rails and currently working with a reservation system can anyone explain what is the difference between current_package = build_reservation_package(:package_id = package_id) abd current_package =reservation_package.build(:package_id = package_id) because i tried using the first one but no good but when i try the second it worked i think both are the same please correct me if im wrong thank I understand the difference between the two builds as follows: I am assuming you are using nested_attributes and if so then my understanding is that in your controller you will be building the reservation_package object so that your form has something to work with. If you have a has_many association then your controller will use the reservation_packages.build option and if you are working with a belongs_to association then you will find that the build_reservation_package is what is called for. I am new to rails as well, but that is what I have gleaned so far ... hope it helps. The table in http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html explains it quite well. For singular relations (has_one, belongs_to) build_other (SINGULAR word) is available For collection (has_many etc.) others.build (PLURAL word) is available. The really interesting part of these 2 build methods is that they delay database interactions until the self object is written to the database (and then the associated records are written together in one transaction, that fails or passes, all or nothing). HTH, Peter -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: difference between %= and %
On Aug 18, 2011, at 6:05 PM, 7stud -- wrote: Tim Shaffer wrote in post #1017353: %= prints the contents of the tag, Well, it never meant that. %= tells ruby to print the result of the expression between the tags. For instance, %= 2+2 % would not print '2 + 2', it would print '4'. But even the result of the expression isn't an entirely accurate description--because in rails 3 you write: %= form_for(@user) do |f| % which doesn't fit that description. In ruby, 'form_for(@user) do | f|' isn't an expression--it's the first half of a loop/block, so it's an incomplete expression. In other words, in ruby if you wrote: result = some_func(arg) do |x| you would get an error. Maybe its best to think of %= form_for() as an exception to the rule? One example of how %= and % differ is this: % 3.times do |i| % divloop: %= i %/div % end % The % tags just execute the ruby code and don't enter any text onto the page, which causes ruby/.erb to loop over the div tag 3 times. The %= tag inside the loop prints the value of the variable i. So you get: divloop: 0/div divloop: 1/div divloop: 2/div Here's another way to look at this. '%=' is a shortcut for '% puts'. There's a similar construction in PHP: '?=' is a shortcut for '?php echo (or print)'. Walter -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between %= and %
Thank you all for your answers! -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between %= and %
And you couldnt just try that out yourself? :D On Aug 18, 7:39 pm, Pepe Sanchez li...@ruby-forum.com wrote: Hi all what is the difference between %= and % in a view file? thanks -- Posted viahttp://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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between %= and %
Tim Shaffer wrote in post #1017353: %= prints the contents of the tag, Well, it never meant that. %= tells ruby to print the result of the expression between the tags. For instance, %= 2+2 % would not print '2 + 2', it would print '4'. But even the result of the expression isn't an entirely accurate description--because in rails 3 you write: %= form_for(@user) do |f| % which doesn't fit that description. In ruby, 'form_for(@user) do |f|' isn't an expression--it's the first half of a loop/block, so it's an incomplete expression. In other words, in ruby if you wrote: result = some_func(arg) do |x| you would get an error. Maybe its best to think of %= form_for() as an exception to the rule? One example of how %= and % differ is this: % 3.times do |i| % divloop: %= i %/div % end % The % tags just execute the ruby code and don't enter any text onto the page, which causes ruby/.erb to loop over the div tag 3 times. The %= tag inside the loop prints the value of the variable i. So you get: divloop: 0/div divloop: 1/div divloop: 2/div -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between attr_accessor and attr_accessible?
On Mar 7, 4:45 pm, Gaba Luschi li...@ruby-forum.com wrote: Hi, What's the difference between attr_accessor and attr_accessible? They're completely unrelated. attr_accessor is a pure ruby method and creates a setter getter method for an instance variable. attr_accessible (and its counterpart attr_protected) are railsisms and are there to control which properties of an object a user can change through mass assignment Fred Is attr_accessor to create a virtual variable/object and attr_accessible makes it accessible? Do you need attr_accessible if you already have attr_accessor? Thanks! -- Posted viahttp://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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between attr_accessor and attr_accessible?
Thanks - what's mass assignment? Assigning attributes to an object? -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between attr_accessor and attr_accessible?
This is mass assignment: User.new(params[:user]) Basically assigning all the attributes to the an instance based on the params[:user] hash. -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes
On Dec 22, 10:38 pm, Marnen Laibow-Koser li...@ruby-forum.com wrote: Let's see your error messages. But why the heck are you defining an object like this anyway? What are you trying to achieve? I'm trying to get a test for acts_as_list working. I've defined a method in test_helper that I use in my unit tests: # tests acts as list and default_scope :order = 'position' def self.should_act_as_list(options = {}) klass = self.name.gsub(/Test$/, ).constantize # converts string to class context acting as a list do setup do # DON'T DO THIS??? #...@instance = klass.all[0] end should have a position column do instance = klass.first assert_not_nil instance.position, :message = If you see me, check out the POSITION. end should move objects correctly do instance = klass.first instance.move_to_bottom assert_equal klass.all[-1], instance instance.move_higher assert_equal klass.all[-2], instance instance.move_to_top assert_equal klass.first, instance instance.move_lower assert_equal klass.all[1], instance end end end My error messages just show this: --- Loaded suite C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/ rake_test_loader Started EE... Finished in 0.171875 seconds. 1) Error: test: An article acting as a list should have a position column. (ArticleTest): NoMethodError: undefined method `position' for nil:NilClass /test/test_helper.rb:36:in `__bind_1293122683_953075' 2) Error: test: An article acting as a list should move objects correctly. (ArticleTest): NoMethodError: undefined method `move_to_bottom' for nil:NilClass /test/test_helper.rb:41:in `__bind_1293122683_953075' 3) Error: test: acting as a list should have a position column. (PageTest): NoMethodError: undefined method `position' for nil:NilClass /test/test_helper.rb:36:in `__bind_1293122684_93700' 4) Error: test: acting as a list should move objects correctly. (PageTest): NoMethodError: undefined method `move_to_bottom' for nil:NilClass /test/test_helper.rb:41:in `__bind_1293122684_93700' 5) Error: test: A section acting as a list should have a position column. (SectionTest): NoMethodError: undefined method `position' for nil:NilClass /test/test_helper.rb:36:in `__bind_1293122684_109325' 6) Error: test: A section acting as a list should move objects correctly. (SectionTest): NoMethodError: undefined method `move_to_bottom' for nil:NilClass /test/test_helper.rb:41:in `__bind_1293122684_109325' 33 tests, 28 assertions, 0 failures, 6 errors rake aborted! Command failed with status (1): [C:/Ruby187/bin/ruby.exe -Ilib;test C:/R...] --- ..which is really the same error over and over again. My variable instance becomes nil somehow. ...and I'm sure that my test db is populated whenever I run my tests... You shouldn't have to be sure of that beforehand; rather, you should be using factories to create records for tests on the fly. I want my development and test dbs to be the same, so I thought using the seeds.rb file - which in my case uses Factories - in conjunction with rake db:seed RAILS_ENV=test would be the best way. There are some things I want to have set names for, like sections - they'll always be Sports, News, etc. Other things like Articles, though, I generate in the seeds file en masse. Is my methodology totally wrong? Should I be testing acts_as_list's functionality in a totally different way? I mean, are you saying I should create records in the setup method for each unit test rather than populate the db with that rake db:seed RAILS_ENV=test command? -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes
daze wrote in post #970337: On Dec 22, 10:38pm, Marnen Laibow-Koser li...@ruby-forum.com wrote: Let's see your error messages. But why the heck are you defining an object like this anyway? What are you trying to achieve? I'm trying to get a test for acts_as_list working. I've defined a method in test_helper that I use in my unit tests: # tests acts as list and default_scope :order = 'position' def self.should_act_as_list(options = {}) klass = self.name.gsub(/Test$/, ).constantize # converts string to class Nonononono. Don't do it that way. With RSpec, you'd write a custom matcher class; I don't know if the same thing is done with Shoulda. But you're getting too complex here and asking for trouble. Please read about how custom should_* methods are supposed to be written. context acting as a list do setup do # DON'T DO THIS??? #...@instance = klass.all[0] end What on earth is that for? should have a position column do instance = klass.first assert_not_nil instance.position, :message = If you see me, check out the POSITION. end That won't actually do what you want -- it will just make sure that position is not nil. You'd have to check the columns array or use respond_to? to do what you're trying for here. should move objects correctly do instance = klass.first instance.move_to_bottom assert_equal klass.all[-1], instance instance.move_higher assert_equal klass.all[-2], instance instance.move_to_top assert_equal klass.first, instance instance.move_lower assert_equal klass.all[1], instance end Probably not necessary -- you're testing acts_as_list here, which is presumably already well tested. You are really doing things the hard way here. Learn a bit more about Ruby's metaprogramming... [...] ...and I'm sure that my test db is populated whenever I run my tests... You shouldn't have to be sure of that beforehand; rather, you should be using factories to create records for tests on the fly. I want my development and test dbs to be the same, No you don't. You want the *schemas* to be the same, but you want only specially crafted test data in your test DB. so I thought using the seeds.rb file - which in my case uses Factories Your seeds file probably should not be using factories. - in conjunction with rake db:seed RAILS_ENV=test would be the best way. There are some things I want to have set names for, like sections - they'll always be Sports, News, etc. Other things like Articles, though, I generate in the seeds file en masse. Is my methodology totally wrong? Yes. Should I be testing acts_as_list's functionality in a totally different way? That's a separate question from seeds. I mean, are you saying I should create records in the setup method for each unit test rather than populate the db with that rake db:seed RAILS_ENV=test command? Yes. Seeding the test database is never a good idea (this is why fixtures are dangerous), because it becomes difficult to make sure your tests don't share state, and also because it becomes difficult to keep track of the assumptions you're making. Use factories to create only the actual records you need for each test case (generally less than 10). And do check out RSpec when you get a chance. :) Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes
Oh whoa okay thanks. I better make some changes now... :/ Can I use Shoulda w/ Rspec, or do I just use one over the other? And I should use this one https://github.com/rspec/rspec-rails, right? -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes
Please quote when replying. daze wrote in post #970358: Oh whoa okay thanks. I better make some changes now... :/ Can I use Shoulda w/ Rspec, or do I just use one over the other? I understand Shoulda is usable with RSpec. I've never actually used Shoulda on any of my projects, though. (And you *should* be able to do what you're doing with Shoulda and Test::Unit.) And I should use this one https://github.com/rspec/rspec-rails, right? rspec-rails works with RSpec to provide some Rails-specific features. Please see http://rspec.info for more information. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes
daze wrote in post #970203: Here's my issue: running ruby -I test test/unit/something_test.rb for each of my unit tests works perfectly. However, running rake test:units brings errors in all of them - some object becomes nil for some reason. And what object is that? Why might this be happening? Specifics: the object that is successfully not nil when I run the unit tests one-by-one but becomes nil when I do rake test:units is defined like this... klass = self.name.gsub(/Test$/, ).constantize instance = klass.first Let's see your error messages. But why the heck are you defining an object like this anyway? What are you trying to achieve? ...and I'm sure that my test db is populated whenever I run my tests... You shouldn't have to be sure of that beforehand; rather, you should be using factories to create records for tests on the fly. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between attr_accesor and attr_accesible
On Dec 21, 12:20 pm, kp pariharkirt...@gmail.com wrote: I m new to ruby language. difference between att_accesor and attr_accessible is not clear to me. They're almost completely unrelated. attr_accessor is part of ruby itself and is equivalent to calling attr_writer and attr_reader for the same argument(s), ie it creates accessor methods for you attr_accessible is a rails thing and is part of rails' mass assignment protection (along with attr_protected). It allows you to setup a whitelist of attributes that can be mass-assigned (as opposed to attr_protected, which sets up a blacklist) so that users can't set important attributes they're not supposed to be able to set just by manipulating the form data that is posted Fred thanks for your kind help. kp (india) -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: difference between attr_accesor and attr_accesible
hey...thanks for help. On Tue, Dec 21, 2010 at 7:07 PM, Frederick Cheung frederick.che...@gmail.com wrote: On Dec 21, 12:20 pm, kp pariharkirt...@gmail.com wrote: I m new to ruby language. difference between att_accesor and attr_accessible is not clear to me. They're almost completely unrelated. attr_accessor is part of ruby itself and is equivalent to calling attr_writer and attr_reader for the same argument(s), ie it creates accessor methods for you attr_accessible is a rails thing and is part of rails' mass assignment protection (along with attr_protected). It allows you to setup a whitelist of attributes that can be mass-assigned (as opposed to attr_protected, which sets up a blacklist) so that users can't set important attributes they're not supposed to be able to set just by manipulating the form data that is posted Fred thanks for your kind help. kp (india) -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.comrubyonrails-talk%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between belongs_to and references keyword?
Kevin Hastie wrote: [...] j) What seems much easier is to have the Business and School tables to each have an address_id, and be done with it. That's correct. That's what I would have done days ago were I programming a language without so many handy shortcuts. But to do so, doesn't it have to be Address has_one :business has_one :school Business belongs_to :address That doesn't seem right..? That's only right if you want an address to treat associated businesses and schools differently. If you just want an address to have_one (or more likely many) associated generic entities, then you need polymorphism. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between belongs_to and references keyword?
i am interested in the answer to this as well. please post if you find out. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between belongs_to and references keyword?
Kevin Hastie wrote: Kevin Hastie wrote: I guess what I really want is something like this: class Address ActiveRecord::Base belongs_to :addressable, :polymorphic = true end class Business ActiveRecord::Base has_one :address, :as = :addressable end class School ActiveRecord::Base has_one :address, :as = :addressable end h) I don't suppose there is a way to do that with the scaffold. Is there a typical set of scaffold options that would map to this? i) Lastly, I guess I am better off avoiding polymorphism at the beginning, huh? I should just be doing a simple mapping... What about the polymorphic example I gave? It seems like this is the best practice approach, but I am finding it VERY hard to find examples that I can get to work, and I feel like I see lots of complaints that the feature is broken within Rails. Is it only for has_many relationships or can it be used like I am trying with has_one relationships? Is my example the correct way to go about it? If so, what else needs to happen? (and what about questions h and i?) j) What seems much easier is to have the Business and School tables to each have an address_id, and be done with it. That's what I would have done days ago were I programming a language without so many handy shortcuts. But to do so, doesn't it have to be Address has_one :business has_one :school Business belongs_to :address That doesn't seem right..? -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between belongs_to and references keyword?
I've written a short example about has_many, belongs_to - http://gist.github.com/425026 has_many, has_one, belongs_to deffinitions goes into model and not in scaffold. You can use references like this: script/generate scaffold address company:references address:text but as I mentioned in this discussion http://railsforum.com/viewtopic.php?id=39325 (look for andain's posts) I'm running into problems where views are generated without appended _id. Maybe I'm just doing something wrong or just not getting it right ... Anyway I hope i shed some light on your problem. On Jun 4, 2:18 am, Kevin Hastie li...@ruby-forum.com wrote: Kevin Hastie wrote: I guess what I really want is something like this: class Address ActiveRecord::Base belongs_to :addressable, :polymorphic = true end class Business ActiveRecord::Base has_one :address, :as = :addressable end class School ActiveRecord::Base has_one :address, :as = :addressable end h) I don't suppose there is a way to do that with the scaffold. Is there a typical set of scaffold options that would map to this? i) Lastly, I guess I am better off avoiding polymorphism at the beginning, huh? I should just be doing a simple mapping... -- Posted viahttp://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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between belongs_to and references keyword?
Correction to my previuos message: you can use belongs_to and references as column types in scaffold (and migrations). They do same thing: add belongs_to association to model. On Jun 4, 9:05 am, Ugis Ozols ugis.ozo...@gmail.com wrote: I've written a short example about has_many, belongs_to -http://gist.github.com/425026 has_many, has_one, belongs_to deffinitions goes into model and not in scaffold. You can use references like this: script/generate scaffold address company:references address:text but as I mentioned in this discussionhttp://railsforum.com/viewtopic.php?id=39325 (look for andain's posts) I'm running into problems where views are generated without appended _id. Maybe I'm just doing something wrong or just not getting it right ... Anyway I hope i shed some light on your problem. On Jun 4, 2:18 am, Kevin Hastie li...@ruby-forum.com wrote: Kevin Hastie wrote: I guess what I really want is something like this: class Address ActiveRecord::Base belongs_to :addressable, :polymorphic = true end class Business ActiveRecord::Base has_one :address, :as = :addressable end class School ActiveRecord::Base has_one :address, :as = :addressable end h) I don't suppose there is a way to do that with the scaffold. Is there a typical set of scaffold options that would map to this? i) Lastly, I guess I am better off avoiding polymorphism at the beginning, huh? I should just be doing a simple mapping... -- Posted viahttp://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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between belongs_to and references keyword?
Kevin Hastie wrote: a) Am I doing this right? Apparently not. Weird. Is it because I didn't do polymorphic anywhere that Address now has a business_id, a credit_card_id and a user_id? Obviously this is no good - I'd prefer the Business table to have an address_id, etc So: e) Did I do this backwards? Should it be Business address:references (or address:belongs_to?) and Address business:has_one? f) Or should I just drop the :references from Addresses and go from there? g) Is using :references (which I don't see in many docs/tutorials) just going to get me in trouble as a beginner? Thanks again! -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between belongs_to and references keyword?
Kevin Hastie wrote: I guess what I really want is something like this: class Address ActiveRecord::Base belongs_to :addressable, :polymorphic = true end class Business ActiveRecord::Base has_one :address, :as = :addressable end class School ActiveRecord::Base has_one :address, :as = :addressable end h) I don't suppose there is a way to do that with the scaffold. Is there a typical set of scaffold options that would map to this? i) Lastly, I guess I am better off avoiding polymorphism at the beginning, huh? I should just be doing a simple mapping... -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between singularized symbol and pluralized sy
John Merlino wrote: Hey all, Does anyone know the difference between a singularized symbol (:student_state) and a pluralized symbol (:student_states). How can they be used differently. Thanks for suggestions. They're completely different symbols. What are you really trying to ask? Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between singularized symbol and pluralized sy
Marnen Laibow-Koser wrote: John Merlino wrote: Hey all, Does anyone know the difference between a singularized symbol (:student_state) and a pluralized symbol (:student_states). How can they be used differently. Thanks for suggestions. They're completely different symbols. What are you really trying to ask? Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org If one stemmed from this: StudentState.name.tableize and then was converted to a symbol (:student_states) and the other stemmed from this: StudentState.name.underscore and then was converted to a symbol (:student_state). StudentState is the model. I see this done all the time. I'm just curious of what different functionality the two provide. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: difference between singularized symbol and pluralized sy
John Merlino wrote: Marnen Laibow-Koser wrote: John Merlino wrote: Hey all, Does anyone know the difference between a singularized symbol (:student_state) and a pluralized symbol (:student_states). How can they be used differently. Thanks for suggestions. They're completely different symbols. What are you really trying to ask? Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org If one stemmed from this: StudentState.name.tableize and then was converted to a symbol (:student_states) and the other stemmed from this: StudentState.name.underscore and then was converted to a symbol (:student_state). StudentState is the model. I see this done all the time. I'm just curious of what different functionality the two provide. Symbols don't provide functionality. They're just data. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between ruby1.8.6 and 1.8.7
Hi Tom, From what I know, Rails 3 won't work with Ruby 1.8.6. There's a fix in Ruby 1.8.7 they count on. Aleksey On Jan 21, 3:50 pm, Tom Mac li...@ruby-forum.com wrote: Hi I am using ruby1.8.6 for development in fedora12 since in yum repository the latest is that. Is there any problem if continuing with that and later migrating to 1.8.7 .Is there any big difference between them? Please share your thoughts Thanks Tom -- Posted viahttp://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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Difference between Mongrel and Webrick
I would actually argue that even Mongrel at this point would be considered deprecated by that definition. Most deploy environments are using Passenger even that is now looking like Unicorn might give it a run. I switched to using Passenger for my dev environment over a year ago. Niels On Jan 14, 2010, at 8:00 PM, Anachronistic wrote: WEBrick was dropped and isn't considered a serious contender. Mongrel replaced it. Even in 2007 you can find mention of WEBrick being semi- deprecated as Mongrel gained favor. Technically, deprecated only means should be avoided in favor of a more suitable alternative. Outright replaced is perhaps more accurate in this case. On Jan 13, 3:22 pm, pharrington xenogene...@gmail.com wrote: On Jan 13, 10:24 am, [AFH] afharri...@gmail.com wrote: Accidentally direct messaged, apologies. WEBrick has basically been deprecated, even for development purposes. Mongrel is faster and more reliable and now the de facto standard in the community. Alan http://www.twitter.com/anachronistic WEBrick isn't depricated. Mongrel main development branch doesn't entirely work with Ruby 1.9 yet, although there seem to be plenty of patches which do appear to work. http://rack.rubyforge.org/doc/has a nice list of popular Ruby webservers. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Difference between Mongrel and Webrick
Niels Meersschaert wrote: I would actually argue that even Mongrel at this point would be considered deprecated by that definition. Most deploy environments are using Passenger even that is now looking like Unicorn might give it a run. I switched to using Passenger for my dev environment over a year ago. Niels Of course for those stuck on Windows for development, Passenger is not an option and Mongrel does the job. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between Mongrel and Webrick
WEBrick was dropped and isn't considered a serious contender. Mongrel replaced it. Even in 2007 you can find mention of WEBrick being semi- deprecated as Mongrel gained favor. Technically, deprecated only means should be avoided in favor of a more suitable alternative. Outright replaced is perhaps more accurate in this case. On Jan 13, 3:22 pm, pharrington xenogene...@gmail.com wrote: On Jan 13, 10:24 am, [AFH] afharri...@gmail.com wrote: Accidentally direct messaged, apologies. WEBrick has basically been deprecated, even for development purposes. Mongrel is faster and more reliable and now the de facto standard in the community. Alan http://www.twitter.com/anachronistic WEBrick isn't depricated. Mongrel main development branch doesn't entirely work with Ruby 1.9 yet, although there seem to be plenty of patches which do appear to work. http://rack.rubyforge.org/doc/has a nice list of popular Ruby webservers. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between Mongrel and Webrick
On Jan 13, 2:51 pm, Rails ROR developra...@gmail.com wrote: Hi Everybody, I would like to know the exact difference between Mongrel and Webrick. I have gone through few sites about Mongrel and Webrick differences. I came to know that Mongrel is fast, efficient than Webrick. Are there any other differences other than this? Which one is better? That is pretty much the main difference - other than that they are pretty similar in scope Are there any other servers other than Mongrel and Webrick. thin and passenger (although you might consider that to be in a slightly different category) are two that spring to mind, there are a bunch more options in the jruby world but that's not something I'm familiar with Fred Thanks in advance. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between Mongrel and Webrick
Accidentally direct messaged, apologies. WEBrick has basically been deprecated, even for development purposes. Mongrel is faster and more reliable and now the de facto standard in the community. Alan http://www.twitter.com/anachronistic -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between Mongrel and Webrick
On Jan 13, 10:24 am, [AFH] afharri...@gmail.com wrote: Accidentally direct messaged, apologies. WEBrick has basically been deprecated, even for development purposes. Mongrel is faster and more reliable and now the de facto standard in the community. Alan http://www.twitter.com/anachronistic WEBrick isn't depricated. Mongrel main development branch doesn't entirely work with Ruby 1.9 yet, although there seem to be plenty of patches which do appear to work. http://rack.rubyforge.org/doc/ has a nice list of popular Ruby webservers. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Difference between Mongrel and Webrick
There's also Unicorn. -- 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 group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Difference between two dates
Rob Olson wrote: Subtracting two dates gives a Rational which is the reason for the integer conversion. why does it return a Rational type? -- 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-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference Between ROR and Django...
Well, if you want to hear what is bad about python, ask here and ask the python people about ruby. As for learning something carrier wise, learn both and learn php and cakephp. If you only know one, you are not very good. Also, you pick one and become really good with it, that is the best advise. I have seen people do awesome things with tools I could not believe in a million years were possible with them, just because they stuck with them. If you want to start somewhere, create a simple blog system with photo albums and comments and tags in both system. Make sure you finish both. Then you decide. Only thing that helps your carrier is being good at something, there are millions of people mediocre in pretty much everything. Trausti On Mon, Aug 17, 2009 at 2:13 PM, Ram Kumar.Kramkumarit2...@gmail.com wrote: Hi I am the newbie to both Django as well as ROR Which one i have to choose as my carrier one And what is the main difference Djkango in Python It is in Ruby.. which one is best to easy learn and about security Thank you... -- WithRegards... K.Ramkumar Blog at http://fallinlinux.wordpress.com/ contact : 97915 89522 --~--~-~--~~~---~--~~ 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...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference Between ROR and Django...
I tried Django when I was focusing on making Python my primary language and. . . I went through a few tutorials, but I could not quite get it. At the time, though, I wasn't terribly familiar with OOP concepts* and when I found myself not being able to access python.org at work (long story), I went and started to work with Ruby; thats when I started to finally understand OOP. From that point, I started to work with Rails and here I am. :) FWIW, I think Django is a fine framework and if I decided to go back to it, it would probably be much easier for me to pick up. That said, If you feel more comfortable with the way Rails work, I personally would just skip it and go for Pylons, since Pylons is similar to Rails in syntax and implementation (as far as I can tell). *I think that's the key - if you don't have a good grasp of OOP, it would be fairly difficult for you to get up and running with any framework, whether it is Django, Rails or any other web MVC. I would suggest brushing up on OOP in your current language or any other language in parallel in learning a MVC framework. On Mon, Aug 17, 2009 at 8:13 AM, Ram Kumar.Kramkumarit2...@gmail.com wrote: Hi I am the newbie to both Django as well as ROR Which one i have to choose as my carrier one And what is the main difference Djkango in Python It is in Ruby.. which one is best to easy learn and about security Thank you... -- WithRegards... K.Ramkumar Blog at http://fallinlinux.wordpress.com/ contact : 97915 89522 -- Rilindo Foster AOL Instant Messenger: rilindo Google Talk: rili...@gmail.com Web Site: http://www.monzell.com Primary: rili...@me.com Secondary: rili...@gmail.com Rich bachelors should be heavily taxed. It is not fair that some men should be happier than others. -- Oscar Wilde --~--~-~--~~~---~--~~ 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...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference Between ROR and Django...
Since you're on a Rails list... I'll keep this short. Django is the best solution (if you like snakes). Ruby on Rails is the best solution (if you like Trains). If you like snakes AND trains... well, you're going to have to evaluate the pros/cons with a different set of metrics. Robby... who likes trains. On Mon, Aug 17, 2009 at 5:13 AM, Ram Kumar.Kramkumarit2...@gmail.com wrote: Hi I am the newbie to both Django as well as ROR Which one i have to choose as my carrier one And what is the main difference Djkango in Python It is in Ruby.. which one is best to easy learn and about security Thank you... -- WithRegards... K.Ramkumar Blog at http://fallinlinux.wordpress.com/ contact : 97915 89522 -- Robby Russell Chief Evangelist, Partner PLANET ARGON, LLC design // development // hosting w/Ruby on Rails http://planetargon.com/ http://robbyonrails.com/ http://twitter.com/planetargon aim: planetargon +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4068 [fax] --~--~-~--~~~---~--~~ 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...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: difference between html.erb and .erb
saljamil wrote: I spend few hours debugging a flash chart issue. At the end and after a lot of trial and error, I switched my view name from dashboard.erb to dashboard.html.erb and that resolved the problem. Any idea why? I tried to google for the difference between the two but could not find anything meaningful. I have a mix of views with only .erb and html.erb in my app. Thanks for the insight. The old Rails views used the extension /rhtml (for Ruby HTML). In newer Rails versions the rendering engine and format have been separated in order to support multiple presentations using the same controller actions. You are saying with dashboard.html.erb is that your view format is HTML using the ERB (Embedded Ruby) rendering engine. But, you can also have other formats and other rendering engines using the same controller. They might look something like this: dashboard.iphone.erb # HTML styles for iPhone using ERB engine dashboard.js.rjs # JavaScript using RJS dashboard.xml.builder # XML format using the XML builder All these other views share the same controller action by using respond_to :format { |format| ... }. -- 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-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: difference between html.erb and .erb
Robert Walker wrote: The old Rails views used the extension /rhtml (for Ruby HTML). In newer Typo correction .rhtml not /rhtml -- 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-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference between include and joins in find?
Sorry, that was my typo. The correct error was: ## table 1: companies ## id int name string ## table 2: sections ## id int ref_company_id int ref_meta_id int sec_name string class Company ActiveRecord has_one :main_section, :class=Section, :foreign_key=ref_company_id, :conditions=ref_meta_id=0 has_many :all_sections, :class=Section, :foreign_key=ref_company_id end class Section ActiveRecord belongs_to :company, :class=Company, :foreign_key=ref_company_id end Company.find(:all, :select='companies.*', :include= [:all_sections], :conditions=sections.sec_name='abc') * Unknown column 'companies.ref_company_id' in 'field list': SELECT `companies`.`id` AS t0_r0, `companies`.`name` AS t0_r1, `companies`.`ref_company_id` AS t0_r2, `companies`.`ref_meta_id` AS t0_r3, `companies`.`sec_name` AS t0_r4, `sections`.`id` AS t1_r0, `sections`.`ref_company_id` AS t1_r1, `sections`.`ref_meta_id` AS t1_r2, `sections`.`sec_name` AS t1_r3, FROM`companies` LEFT OUTER JOIN `sections` ON sections.ref_meta_id = companies.id WHERE ( sections.sec_name='abc' ) ** the werid part is `companies`.`ref_company_id` AS t0_r2, `companies`.`ref_meta_id` AS t0_r3, `companies`.`sec_name` AS t0_r4, For now, though I am using :join and :group to get what I want. I still got no idea where these errors came from when using :include. On Nov 19, 4:28 pm, Frederick Cheung [EMAIL PROTECTED] wrote: On 18 Nov 2008, at 23:41,bobluwrote: yes, the compannies table does not have a columns called ref_company_id. It is the table which is referreced by the sections table that has a ref_company_id as a foreign key. Can you explain why that error comes out? 'cause I cannot find any clue about it. It's very weird - in particular it's weird that it goes t0_r0, t0_r16: the number after the r is generated by an each_with_index loop - it should skip over the numbers 1-15. Weird stuff might happen if you had overwritten the column_names or columns methods on your ActiveRecord class but I would have expected that to cause problems elsewhere too. Fred And thank you for mentioning your blog post, and I now know why I feel my app is much faster using join than using include. Thank you. On Nov 18, 7:37 pm, Frederick Cheung [EMAIL PROTECTED] wrote: Well to answer the question in the subject line, I wrote this a little while back:http://www.spacevatican.org/2008/6/22/the-difference-between-include- ... A key thing to note is that include in 2.1 and include in 2.0.2 are different (but the 2.1 code will fall back to the 2.0.2 code if necessary). Does the companies table not have columns called ref_company_id ? Fred --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference between include and joins in find?
I finally get this right. Here is the conclution. In find method, use :join=[:association_name] will simply do a 'full join', which drop all rows that do not match the association conditions. use :join=['join table_b on table_a.id=table_b.xx'], this is a 'full join' too. use :join=['left(or right) join table_b on table_a.id=table_b.xx'], this is the usual left or right join. use :include=[:association_name] will be supposed to do a 'left outer join', this will work most of the time. but I don't know why it sometimes generates wierd SQL statement like this. ## table 1: companies ## id int . ## table 2: sections ## id int ref_company_id int ref_meta_id int # class Company ActiveRecord # has_one :main_section, :class=Section, :foreign_key=ref_company_id, :conditions=ref_meta_id=0 # has_many :all_sections, :class=Section, :foreign_key=ref_company_id # end # class Section ActiveRecord # belongs_to :company, :class=Company, :foreign_key=ref_company_id # end Company.find(:all, :select='companies.*', :include= [:all_sections], :conditions=sections.id500) * Unknown column 'companies.ref_company_id' in 'field list': SELECT `companies`.`id` AS t0_r0, `companies`.`ref_company_id` AS t0_r16, `companies`.`ref_meta_id` AS t0_r17, `sections`.`id` AS t1_r0, `sections`.`ref_company_id` AS t1_r1, `sections`.`ref_meta_id` AS t1_r2, FROM`companies` LEFT OUTER JOIN `sections` ON sections.ref_meta_id = companies.id WHERE ( sections.id500 ) ** On Nov 18, 2:57 pm, boblu [EMAIL PROTECTED] wrote: OK. I figured out that join is actually doing an inner join which filters the rows that don't have association. And include is actually doing an 'outter join' which shows all the rows from tables. But, however, I still can not figure out why that strange SQL statement comes out. Can anyone please help me? On Nov 18, 1:52 pm, boblu [EMAIL PROTECTED] wrote: I had real weird problem here. If I use joins in find, both development and production environment give right answers. But, when I use include in find, the development environment goes all right. However, the find method fails in production enviroment. Let me describe this in detail. I have two tables. ## table 1: companies ## id int . ## table 2: sections ## id int ref_company_id int ref_meta_id int A company will have one section, and a section may have sub-sections. when ref_meta_id is 0, the section is the main section of a company whose id is ref_company_id. when ref_meta_id is not 0, the section is a sub-section of a company whose id is ref_company_id. And here are the two models # class Company ActiveRecord # has_one :main- section, :class=Section, :foreign_key=ref_company_id, :conditions=ref_meta_id=0 # has_many :all- sections, :class=Section, :foreign_key=ref_company_id # end # class Section ActiveRecord # belongs_to :company, :class=Company, :foreign_key=ref_company_id # end All these things are good in both development and production environment. # Company.find(1).main-section # Company.find(1).all-sections # Section.find(1).company Now comes to the find method used in controller. First use joins, as I said before, the following methods went well in both development and production enviroment. # Company.find(:all, :select='companies.*', :joins=[:all- sections], :conditions=companies.id500) # Company.find(:all, :select='companies.*', :joins=[:all- sections], :conditions=sections.id500) Then use include, # Company.find(:all, :select='companies.*', :joins=[:all- sections], :conditions=companies.id500) this went well in both development and production enviroment. However, # Company.find(:all, :select='companies.*', :joins=[:all- sections], :conditions=sections.id500) this went well in development environment, but in production environment, I get this error. * Unknown column 'companies.ref_company_id' in 'field list': SELECT `companies`.`id` AS t0_r0, `companies`.`ref_company_id` AS t0_r16, `companies`.`ref_meta_id` AS t0_r17, `sections`.`id` AS t1_r0, `sections`.`ref_company_id` AS t1_r1, `sections`.`ref_meta_id` AS t1_r2, FROM `companies` LEFT OUTER JOIN `sections` ON sections.ref_meta_id = companies.id WHERE ( sections.id500 ) ** And this is definetely a wrong SQL statement Can anybody explain this? And Can anybody please explain what is the difference between
[Rails] Re: Difference between include and joins in find?
Well to answer the question in the subject line, I wrote this a little while back: http://www.spacevatican.org/2008/6/22/the-difference-between-include-and-joins A key thing to note is that include in 2.1 and include in 2.0.2 are different (but the 2.1 code will fall back to the 2.0.2 code if necessary). Does the companies table not have columns called ref_company_id ? Fred --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference between include and joins in find?
yes, the compannies table does not have a columns called ref_company_id. It is the table which is referreced by the sections table that has a ref_company_id as a foreign key. Can you explain why that error comes out? 'cause I cannot find any clue about it. And thank you for mentioning your blog post, and I now know why I feel my app is much faster using join than using include. Thank you. On Nov 18, 7:37 pm, Frederick Cheung [EMAIL PROTECTED] wrote: Well to answer the question in the subject line, I wrote this a little while back:http://www.spacevatican.org/2008/6/22/the-difference-between-include-... A key thing to note is that include in 2.1 and include in 2.0.2 are different (but the 2.1 code will fall back to the 2.0.2 code if necessary). Does the companies table not have columns called ref_company_id ? Fred --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference between include and joins in find?
Harold to me As far as I know, the reason for :include is mainly for eager loading. If you know you will be querying the sections table for the companies you are finding, doing an :include will retrieve those sections in one query, ie, one trip to the DB. If you don't pass in the :include option to the initial find, doing the_company.all-sections would go to the database to retrieve the associated records and then build the section object. I usually use :joins when I want to narrow down the search even further, for instance, to companies who have sections, persons who also have users, etc. For example: Company.find(:all, :include = :all-sections, :conditions = '...') Would fetch all companies meeting those conditions, along with the associated all-sections. Therefore it doesn't make sense to force it to :select any specific columns, especially not columns on only one of the tables - it defeats the purpose of the :include. On the other hand: Company.find(:all, :joins = :all-sections, :conditions = '..', :select = 'company.*') works fine, however, :select = 'company.*' is redundant, and if you will need the returned companies' sections, you will make a trip to the DB that may have been avoided by using :include. On Nov 18, 6:41 pm, boblu [EMAIL PROTECTED] wrote: yes, the compannies table does not have a columns called ref_company_id. It is the table which is referreced by the sections table that has a ref_company_id as a foreign key. Can you explain why that error comes out? 'cause I cannot find any clue about it. And thank you for mentioning your blog post, and I now know why I feel my app is much faster using join than using include. Thank you. On Nov 18, 7:37 pm, Frederick Cheung [EMAIL PROTECTED] wrote: Well to answer the question in the subject line, I wrote this a little while back:http://www.spacevatican.org/2008/6/22/the-difference-between-include-... A key thing to note is that include in 2.1 and include in 2.0.2 are different (but the 2.1 code will fall back to the 2.0.2 code if necessary). Does the companies table not have columns called ref_company_id ? Fred --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference between include and joins in find?
On 18 Nov 2008, at 23:41, boblu wrote: yes, the compannies table does not have a columns called ref_company_id. It is the table which is referreced by the sections table that has a ref_company_id as a foreign key. Can you explain why that error comes out? 'cause I cannot find any clue about it. It's very weird - in particular it's weird that it goes t0_r0, t0_r16: the number after the r is generated by an each_with_index loop - it should skip over the numbers 1-15. Weird stuff might happen if you had overwritten the column_names or columns methods on your ActiveRecord class but I would have expected that to cause problems elsewhere too. Fred And thank you for mentioning your blog post, and I now know why I feel my app is much faster using join than using include. Thank you. On Nov 18, 7:37 pm, Frederick Cheung [EMAIL PROTECTED] wrote: Well to answer the question in the subject line, I wrote this a little while back:http://www.spacevatican.org/2008/6/22/the-difference-between-include- ... A key thing to note is that include in 2.1 and include in 2.0.2 are different (but the 2.1 code will fall back to the 2.0.2 code if necessary). Does the companies table not have columns called ref_company_id ? Fred --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference between include and joins in find?
OK. I figured out that join is actually doing an inner join which filters the rows that don't have association. And include is actually doing an 'outter join' which shows all the rows from tables. But, however, I still can not figure out why that strange SQL statement comes out. Can anyone please help me? On Nov 18, 1:52 pm, boblu [EMAIL PROTECTED] wrote: I had real weird problem here. If I use joins in find, both development and production environment give right answers. But, when I use include in find, the development environment goes all right. However, the find method fails in production enviroment. Let me describe this in detail. I have two tables. ## table 1: companies ## id int . ## table 2: sections ## id int ref_company_id int ref_meta_id int A company will have one section, and a section may have sub-sections. when ref_meta_id is 0, the section is the main section of a company whose id is ref_company_id. when ref_meta_id is not 0, the section is a sub-section of a company whose id is ref_company_id. And here are the two models # class Company ActiveRecord # has_one :main- section, :class=Section, :foreign_key=ref_company_id, :conditions=ref_meta_id=0 # has_many :all- sections, :class=Section, :foreign_key=ref_company_id # end # class Section ActiveRecord # belongs_to :company, :class=Company, :foreign_key=ref_company_id # end All these things are good in both development and production environment. # Company.find(1).main-section # Company.find(1).all-sections # Section.find(1).company Now comes to the find method used in controller. First use joins, as I said before, the following methods went well in both development and production enviroment. # Company.find(:all, :select='companies.*', :joins=[:all- sections], :conditions=companies.id500) # Company.find(:all, :select='companies.*', :joins=[:all- sections], :conditions=sections.id500) Then use include, # Company.find(:all, :select='companies.*', :joins=[:all- sections], :conditions=companies.id500) this went well in both development and production enviroment. However, # Company.find(:all, :select='companies.*', :joins=[:all- sections], :conditions=sections.id500) this went well in development environment, but in production environment, I get this error. * Unknown column 'companies.ref_company_id' in 'field list': SELECT `companies`.`id` AS t0_r0, `companies`.`ref_company_id` AS t0_r16, `companies`.`ref_meta_id` AS t0_r17, `sections`.`id` AS t1_r0, `sections`.`ref_company_id` AS t1_r1, `sections`.`ref_meta_id` AS t1_r2, FROM `companies` LEFT OUTER JOIN `sections` ON sections.ref_meta_id = companies.id WHERE ( sections.id500 ) ** And this is definetely a wrong SQL statement Can anybody explain this? And Can anybody please explain what is the difference between include and join? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Difference between Collection, method and action
Robin Cua wrote: Hi, what are the differences between Collection, Method and Action? How to call each? Collection: An array of objects, resources, etc. Method: A function that is scoped within a class or object instance in an Object Oriented Program (OOP). Action: A special method that is defined in a controller object in a Model-View-Controller design. The action is no different in reality from any other method. It's only differentiated by how, and where, it is used. Controller objects have methods. Some of these methods are referred to as actions because they are typically called as a result of some event. In a web application that typically means the event is an HTTP request. The duty of the action method is to process the request by sending messages to the model and view objects to generate an HTTP response. The response body can be HTML, JavaScript, PDF (or any other binary file), RSS/ATOM, etc. -- 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-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: difference between model and scaffold generators
On Oct 5, 4:01 pm, Jay Pangmi [EMAIL PROTECTED] wrote: Hi, among lots other confusions herez one.. I found two kinda similar (:to me) = script/generate model business name:string address:string location_id:integer AND script/generate scaffold business name:string address:string location_id:integer but with model I couldn't do this:http://localhost:port-number/businesses but with scaffold this url came with the option to give input which is saved in the database. So, I don't use model but scaffold. So, can someone plz lighten me up on this. thnx.. model just genenates the model. Scaffold generates a controller and views too. Fred -- Posted viahttp://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-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: ****[Rails] Re: difference between model and scaffold generators
On Sun, 2008-10-05 at 08:48 -0700, Frederick Cheung wrote: On Oct 5, 4:01 pm, Jay Pangmi [EMAIL PROTECTED] wrote: Hi, among lots other confusions herez one.. I found two kinda similar (:to me) = script/generate model business name:string address:string location_id:integer AND script/generate scaffold business name:string address:string location_id:integer but with model I couldn't do this:http://localhost:port-number/businesses but with scaffold this url came with the option to give input which is saved in the database. So, I don't use model but scaffold. So, can someone plz lighten me up on this. thnx.. model just genenates the model. Scaffold generates a controller and views too. correct me if I'm wrong but I thought... script/generate model SOME_MODEL would also generate a migration script too Craig --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---