[Rails] rspec test cannot be passed when render partial in layout
I have a problem stuck me couples of days, could anyone help me? Thanks very much. The problem is that rspec test cannot be passed when the layout contains :partial, once i removed the :partial, the rspec test passed successfully. I could not find out the reason. Below is my code: application.html.erb <%= render :partial => 'shared/header' %> <%= yield %> <%= render :partial => 'shared/footer' %> users_controller_spec.rb describe UsersController do describe "Requesting /forgot_password using GET" do it "should be successful" do get :forgot_password end end end --~--~-~--~~~---~--~~ 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: Opening file content into a textarea
in ruby there is the class File: http://www.ruby-doc.org/core/classes/File.html to get the contents of your file try something like: my_file = File.new(path_to_file, 'r') @my_file_content = my_file.read my_file.close now you can show your content inside the text area (you should know how to build a simple form for it). after editing it, back in your controller write the updated contents to the file: updated_content = params[:whatever] my_file = File.new(path_to_file, 'w') my_file.write(updated_content) my_file.close --~--~-~--~~~---~--~~ 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: form_remote_tag comes back before saving really done?
Ha! current_user.pending_friends_by_me.reload Yeah that fixed it! Thanks MaD! -- 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: form_remote_tag comes back before saving really done?
try a current_user.reload or current_user.pending_friends_by_me.reload in your controller after the save. maybe this helps. --~--~-~--~~~---~--~~ 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: Download Movie through link
if i understand correctly you can click that link, choose the option 'save as', download it to you hd and watch it. but you if you click the link and choose 'open', your video player opens but doesn't show any content. correct? if so i don't think it's a problem with your rails app, but with your operating system. because as i understand it, the file gets send correctly. maybe try another video-player. are you able to open other videos on the net (maybe upload one to a ftp and open it with your browser)? --~--~-~--~~~---~--~~ 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: Class Library for RoR
don't what exactly you are looking for, but there is the ruby-api and the rails-api: http://www.ruby-doc.org/core/ http://api.rubyonrails.org/ --~--~-~--~~~---~--~~ 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: Rails Music Composer
Interesting :-) -- 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] Download Movie through link
Hi, I am storing movie data into db. Now I want to access movie from db and create a link to allow download movie. But when I click on the link It simply open the movie player and does not play the movie. player give error in movie file. When I try to save_as link and save the movie file and play It work's fine. My code like: === Controller def download @movie = Movies.find(params[:file]) @headers["Content-Type"] = "video/x-ms-wmv; charset=utf-8" render :text => @movie.file end === View <%= link_to movie.filename, {:action => 'download', :id => movie.filename, :file => movie.id }%> === I just want to make a this link download on single click so it prompt me. Please let me know what can I do ? I really need some help. Regards, Deepak -- 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] form_remote_tag comes back before saving really done?
Hi, I am having troubles with a form_remote_tag. I have this form: <% form_remote_tag :url => { :action => 'create', :controller => 'invitations' } do %> <%= hidden_field_tag 'invite', user.id %> <%= hidden_field_tag 'command', 'invite_user' %> <%= submit_tag('Invite') %> <% end %> That ends up if the a controllers function (after entering from create...): def invite_user(friend_to_invite) invited_user = User.find(friend_to_invite) current_user.request_friendship_with(invited_user) invitation = Invitation.new invitation.user_id = current_user.id invitation.status = 0 if invitation.save @pending_friends_by_me = current_user.pending_friends_by_me puts "@pending_friends_by_me" puts @pending_friends_by_me puts "/@pending_friends_by_me" render :update do |page| page[:sent_invitations].replace_html :partial => "sent_invitations" end return end end _sent_invitations is the partial that shows the contents of @pending_friends_by_me. So you press the button on the form and this partial is updated with the current invitations sent. THE PROBLEM Whe the partial is updated from the function above it still doesn't contain the updated @pending_friends_by_me, the last invitation is not visible. It returns to the view but the contents are still the same. If I just refresh the page then the partial gets all the invitations. How to solve this? - I went to the model and used the after_save callback, when that is called inspecting the invitations then all of them are already present. But didn't have access to render functions there, and I don't think I should actually call it from ther anyway. Any hints? Thanks. -- 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] Opening file content into a textarea
Hello, Can somebody help me on how to open a file and show it on a text area, and be able to edit it and save it again. Thanks, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: validates_presence_of - only on edit
hey thanks that was the trick, much appreciated On Feb 11, 11:54 am, Philip Hallstrom wrote: > > Ok so not sure if this is possible but it would help out a lot if it > > is. I am trying to put this validation on one of my forms > > > validates_presence_of :name, :state > > > however I only need this validation to run when they edit this form, > > not when they create it. is this possible, any suggestions would be > > greatly appreciated. thanks in advance. > > Check the docs... it's in there. > > # on - Specifies when this validation is active (default is :save, > other options :create, :update). > > validates_presence_of :name, :state, :on => :update > > -philip --~--~-~--~~~---~--~~ 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: validates_presence_of - only on edit
hey thanks that was the trick, much appreciated On Feb 11, 11:54 am, Philip Hallstrom wrote: > > Ok so not sure if this is possible but it would help out a lot if it > > is. I am trying to put this validation on one of my forms > > > validates_presence_of :name, :state > > > however I only need this validation to run when they edit this form, > > not when they create it. is this possible, any suggestions would be > > greatly appreciated. thanks in advance. > > Check the docs... it's in there. > > # on - Specifies when this validation is active (default is :save, > other options :create, :update). > > validates_presence_of :name, :state, :on => :update > > -philip --~--~-~--~~~---~--~~ 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: ar-extensions-0.8.0 - "ActiveRecord::Extensions::FindToCSV"
Hey, Seems I found out the solution. Ha Ha.. ar-extensions-0.8.0 is not compatible with any rails version below 2.0.2. can refer to this site http://www.continuousthinking.com/tags/arext Regards, Anand. Anand Srinu wrote: > Hi All, > > Facing some problem with the new version of the ar-extensions-0.8.0. > With the previous version of this ar-extensions-0.7.0, I was able to use > the > "include ActiveRecord::Extensions::FindToCSV" without any problems. > > When I had upgraded the version of ar-extensions to 0.8.0, I started > getting this error > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:263:in > `load_missing_constant': uninitialized constant > ActiveRecord::Extensions::FindToCSV (NameError) > > So, is there any other kind of library I need to add or something? > > I am using > > ruby > ruby 1.8.6 (2007-03-13 patchlevel 0) [sparc-solaris2.10] > > rails > rails (1.2.5, 0.13.1) > > ar-extensions > ar-extensions (0.8.0, 0.7.0) > > actionmailer (2.0.2, 1.3.6, 1.3.5, 1.0.1) > actionpack (2.0.2, 1.13.6, 1.13.5, 1.9.1) > actionwebservice (1.2.6, 1.2.5, 0.8.1) > activerecord (1.15.6, 1.15.5, 1.11.1) > activeresource (2.0.2) > activesupport (2.0.2, 1.4.4, 1.1.1) > acts_as_paranoid (0.3.1) > acts_as_versioned (0.2.3) > > Thanks in advance, > Regards, > Anand -- 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] bundle_fu making my app very slow
Hi, I tried the bundle_fu plugin, and as of moving to production, I noticed, that my views render in 70ms without bundle_fu, and about 1800ms with it! It's not always 1800 but most of the time. Is this ok? Shouldn't I turn some caching in bundle_fu to on? --~--~-~--~~~---~--~~ 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] ar-extensions-0.8.0 - "ActiveRecord::Extensions::FindToCSV"
Hi All, Facing some problem with the new version of the ar-extensions-0.8.0. With the previous version of this ar-extensions-0.7.0, I was able to use the "include ActiveRecord::Extensions::FindToCSV" without any problems. When I had upgraded the version of ar-extensions to 0.8.0, I started getting this error /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:263:in `load_missing_constant': uninitialized constant ActiveRecord::Extensions::FindToCSV (NameError) So, is there any other kind of library I need to add or something? I am using ruby ruby 1.8.6 (2007-03-13 patchlevel 0) [sparc-solaris2.10] rails rails (1.2.5, 0.13.1) ar-extensions ar-extensions (0.8.0, 0.7.0) actionmailer (2.0.2, 1.3.6, 1.3.5, 1.0.1) actionpack (2.0.2, 1.13.6, 1.13.5, 1.9.1) actionwebservice (1.2.6, 1.2.5, 0.8.1) activerecord (1.15.6, 1.15.5, 1.11.1) activeresource (2.0.2) activesupport (2.0.2, 1.4.4, 1.1.1) acts_as_paranoid (0.3.1) acts_as_versioned (0.2.3) Thanks in advance, Regards, Anand -- 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] Class Library for RoR
I just wonder if anyone is aware of the existence of any RoR class library, please provide any information if you do. Many thanks, Mags -- 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] Rails Music Composer
I have just Created a Rails online music composing site. That allows users to create new musical compositions based off the Conversion of text into a midi Composition and then can be used with any software sequencer such as Reason 4 or GarageBand.. Compose Share & Enjoy.. http://text2midi.herokugarden.com Gabrielg1976 --~--~-~--~~~---~--~~ 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: insert rails into php
Frederick Cheung wrote: > On 11 Feb 2009, at 10:37, Sniper Abandon wrote: > apache, nginx etc... can certainly forward the request to different > places based on the url (and other things). Where things might get > complicated is to what extent your php bits and your rails bits will > need to share information > > Fred thx Fred i have one more problem i want to create subdomain for their profile url accordingly to user_name for example i have url (http://localhost:3000/) if any person login as "user_name" then his profile page url should be http://user_name.localhost:3000/ any idea ? -- 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: Reset password facility
On Wed, Feb 11, 2009 at 11:35 PM, Shockmeister wrote: > > I have used a sha256 hashing algorithm in order to provide some > security to my login facility. I now want to create a facility > whereby, if the user forgets their password, they are emailed a > temporary password so that they can login. Has anyone had any > experience implementing this? > > > Generally if you're using a hash to store the password, then you will need to send users to a page where they can enter a new password. You can do this by generating a temporary token (random value) that you include in a url you mail to the user and set it to expire within a few minutes of being generated. Make sure it's enough time for the password to be reset. Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain --~--~-~--~~~---~--~~ 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] 2 button_to functions for file downloads
I have 2 button_to functions that download 2 different files. the first one acts like a submit and the second on actually does downlaod the file. Does anyone know what would cause that? <%= button_to 'Download PCCIS file',:action => 'downloadpccis' %> <%= button_to 'Download CIS file', :action => 'downloadcis' %> --~--~-~--~~~---~--~~ 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: Refactoring RJS
Hi Fred, thanks so much for your response, that is exactly what I was looking for. What do you mean by rjs can be a bit of a crutch? What do you mean by rewriting the whole thing as a js function. You mean just something like resetVisibility() and then just reset both the end_drop and start_drop elements within the resetVisibility function? Thanks for your help, Dave On Feb 11, 4:17 am, Frederick Cheung wrote: > On 11 Feb 2009, at 10:41, David wrote: > > > > > > > I have some RJS that could use some refactoring. I use the function > > called with afterFinish twice and Im wondering what the best way to > > refactor is. This is all inline rjs in the controller mind you: > > > page.visual_effect :slide_down, "add_appt_#{params > > [:day]}", :afterFinish => "function(){ > > $('end_drop_#{params[:day]}_#{params > > [:appt_counter]}').style.display = 'block'; > > $('end_drop_#{params[:day]}_#{params > > [:appt_counter]}').style.visibility = 'hidden'; > > $('start_drop_#{params[:day]}_#{params > > [:appt_counter]}').style.display = 'block'; > > $('start_drop_#{params[:day]}_#{params > > [:appt_counter]}').style.visibility = 'hidden'; > > }" > > Yummy :-). if you're using prototype you can replace > > $('end_drop_foo').style.display = 'block'; > $('end_drop_foo').style.visibility = 'hidden'; > > with > > $('end_drop_foo').setStyle({display: 'block', visibility: 'hidden'}) > > If i were you I'd have in my application.js a function like > > function resetVisibility(element){ > element.setStyle({display: 'block', visibility: 'hidden'}) > > } > > then then your rjs stuff looks like > > resetVisibility('end_drop_#{params[:day]}_#{params[:appt_counter]}') > resetVisibility('start_drop_#{params[:day]}_#{params[:appt_counter]}') > > or even right the whole thing as a js function (RJS can be a bit of a > crutch) > > 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: How to prevent users from looking at other user's data
On Feb 11, 12:31 pm, Robert Walker wrote: > Gerwin wrote: > > Say I have Users. A user can login and create e.g. Houses..and Houses > > can contain People ..etc. > > > How do I prevent another logged in user from accessing another user's > > House (e.g.http://test.com/houses/1 -> where id=1 doesn't belong to > > this user but to another user). > > > Would People also need to have a user_id field so I can check if the > > request was done by the correct user? > > There are various ways to accomplish this but basically you want to make > sure houses can only be accesses through a user. > > HousesController > --- > def index > user = User.find(current_user) > @houses = user.houses.find(1) > ... > ... > end > > That's the basic idea anyway. > -- > Posted viahttp://www.ruby-forum.com/. Thanks! I didn't know that something like current_user.houses.people.find_by_id(param[:id]) would work :) --~--~-~--~~~---~--~~ 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: Confuse with AR association
It depends whether there are more than one or not. A class is the blueprint of an instance object. Thus a physician class describes one object, of class physician. Has many means one physician has a collection of some other kind of object. Belongs to means a physician can be part of A collection of physicians for another class of object and is therefore the other 'side' if you will. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 12/02/2009, at 3:19 AM, Valentino Lun wrote: > > Dear all > > Refer to http://guides.rails.info/association_basics.html > > Why :physician and :patient some with (s), and some not...? It > actually > refer to the class name or table name? ** really confuse >_<. Can > someone explain it? Is it a convention of rail? Thank you. > > class Physician < ActiveRecord::Base > has_many :appointments > has_many :patients, :through => :appointments > end > > class Appointment < ActiveRecord::Base > belongs_to :physician > belongs_to :patient > end > > class Patient < ActiveRecord::Base > has_many :appointments > has_many :physicians, :through => :appointments > end > > Many thanks > Valentino > -- > 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] Transaction block still sets id on model/new_record to false on rollback
I'm on Rails 2.2.2 on MySQL with InnoDB table types. I'm running into a wierd bug where if I have two models in a transaction and the second model raises an exception, the first model still has it's ID set and it's new_record status set to false despite the row the ID is set to never existing. The following is a console session showing this: >> client_user = new_client_user( :first_name => nil ) # Will cause validation >> to fail => # >> establishment = new_establishment( :brand => brand ) => # >> Establishment.transaction{ establishment.save!; client_user.save! } rescue >> false => false >> establishment.id => 10 >> establishment.new_record? => false >> client_user.id => nil >> establishment.reload ActiveRecord::RecordNotFound: Couldn't find Establishment with ID=10 >> Establishment.count => 4 Here's an explanation of the session: 1) I initialise a new client user, with first_name set to nil so it will fail a validation 2) I then initialise a new establishment model 3) I try and save both in a transaction block. The client_user.save! call raises an exception causing the block to roll back. 4) Yet establishment has an ID set to 10 and is marked as not being a new record. 5) As expected client_user has no ID 6) Calling reload on establishment throws an error because the row does not exist 7) Counting up the actual rows we see it is below the ID assigned to establishment (I did this a few times, the first time the assigned ID was 5, then 6, then 7 etc) Am I missing something or is this expected behaviour? --~--~-~--~~~---~--~~ 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: setting up remote rails
- Does the server have firewall? What does your database.yml look like? --- production: username: mysql_user adapter: mysql port: 3306 host: 127.0.0.1 password: mysql_password database: my_database --~--~-~--~~~---~--~~ 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] Column not in table (legacy database)
I have been pushing my way through the issues regarding using legacy database tables and I am making some progress but have run into a couple of challenges. The test application I am working with has an employee master file that has a primary key called "emssan". I have an employee job record that has a primary key of "shssn". There is one, and only one, job record for each employee record. I needed to join to the employee master file to get the name to display on the job record so I built this relationship: class Job < ActiveRecord::Base set_primary_key "shssn" def self.table_name() "psts301" end belongs_to :employee, :foreign_key => "shssn" end class Employee < ActiveRecord::Base has_one :job set_primary_key "emssan" def self.table_name() "peis301" end def name "#{emfnam} #{emlnam}" end end When I display the index, I get a list of employees with names. Great. When I take the option to show the record, I get a record returned to view. However, if I take the option to create or edit, I get an error Request Failed (code 500, Internal Error) The log shows the following: Column EMPLOYEE_ID not in table PSTS301 The question is: Why is Rails looking for a key called EMPLOYEE_ID when I set the primary key value to "emssan"? How do I fix this? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Trying to make this application RESTy
Ok, here's the basic workflow: 1) A user inputs an order for a customer. This consists of several line items of equipment rental. (So, for example, 3 trucks at 7 am, 7:30, and 8am for June 23). (Ok, this part is easy... a standard Order resource with the usual CRUD actions) 2) A user (may be the same as #1, or may not) must fulfill the order, so he must be able to pull up a list of unassigned work (for a particular day, for example), see this work is still unassigned and assign 3 trucks to this job. (This is where things get fuzzy. Is this specialized index action on Order? I don't think so because we're editing the orders, not just listing them. Is this a separate resource?) 3) A user (may be the same, may not) must later go back and fill out the hours the trucks actually worked, so they must first be able to pull up a list of all work which has been completed to date and see this work has been assigned but not yet recorded. (Same problem... is this another resource, or another view on the resource in number 2?) --~--~-~--~~~---~--~~ 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] Rails 2.2, abstract_class, and associations
In my project, I've created an abstract model that my real models inherit from. In my abstract model, I've overridden method_missing so that I can use attribute names without the field type prefix from the legacy database, without having to set up alias_attribute for every attribute in every table. class LegacyModel < ActiveRecord::Base self.abstract_class = true def method_missing(symbol, *args) ...do some stuff... end end This all worked fine in Rails 2.0.2. It still works in Rails 2.2.2, but now not across a belongs_to association. It does work across a has_many association. NoMethodError: NoMethodError from /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/ associations/association_proxy.rb:209:in `method_missing' Anyone have any ideas on either a better way to handle the attribute names, or where to start looking to figure out how to make this work? Thanks, Jim Crate Que Viva, LLC --~--~-~--~~~---~--~~ 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: setting up remote rails
Have you installed the MySQL gem? On Wed, Feb 11, 2009 at 3:48 PM, The Dro wrote: > > I've got a remote machine on my network which has Ubuntu as the OS. I > run my testserver on it with all my current PHP sites. All I have to > type on my main Vista Machine as the URL is "http://testserver"; and it > takes me to the index page i've created with links to all my sites on > that remote Ubuntu machine. > > My question is: > I've setup RoR on that machine, but when I type testserver:3000 it > wont access that page. On the machine itself, I am able to see my RoR > project, but not on my main machine. I'm even able to SSH into the > testserver to work on the project files. How do I go about setting > that up? > > My second Question is, Where are the config files to tell RoR to use > the MySQL database I currently have setup on the testserver that > phpmyadmin is also using? I have edited the database.yml file to > include the correct login information and the mysql adapter but it's > still not connecting properly to the database. Is there a certain file > I can setup the paths in for my MySQL db? > > thanks in advance for your assistance, > -dro > > > > --~--~-~--~~~---~--~~ 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] setting up remote rails
I've got a remote machine on my network which has Ubuntu as the OS. I run my testserver on it with all my current PHP sites. All I have to type on my main Vista Machine as the URL is "http://testserver"; and it takes me to the index page i've created with links to all my sites on that remote Ubuntu machine. My question is: I've setup RoR on that machine, but when I type testserver:3000 it wont access that page. On the machine itself, I am able to see my RoR project, but not on my main machine. I'm even able to SSH into the testserver to work on the project files. How do I go about setting that up? My second Question is, Where are the config files to tell RoR to use the MySQL database I currently have setup on the testserver that phpmyadmin is also using? I have edited the database.yml file to include the correct login information and the mysql adapter but it's still not connecting properly to the database. Is there a certain file I can setup the paths in for my MySQL db? thanks in advance for your assistance, -dro --~--~-~--~~~---~--~~ 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] Reset password facility
I have used a sha256 hashing algorithm in order to provide some security to my login facility. I now want to create a facility whereby, if the user forgets their password, they are emailed a temporary password so that they can login. Has anyone had any experience implementing this? --~--~-~--~~~---~--~~ 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: Problem registering Mime type
Solved the problem! This is weird though, I had to put "Mime::Type.register "application/pdf", :pdf" after the initializer code. The following thing worked for me, environment.rb: RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION require File.join(File.dirname(__FILE__), 'boot') #Pagination require 'rubygems' require 'google_chart' require 'prawn' Rails::Initializer.run do |config| end require 'will_paginate' Mime::Type.register "application/pdf", :pdf #Dealing with numbers require 'bigdecimal' require 'bigdecimal/math' BigDecimal.mode(BigDecimal::ROUND_MODE,BigDecimal::ROUND_HALF_EVEN) BigDecimal.limit(20) Explanation? anybody? Aslam Syed wrote: > I am facing problem trying to register pdf Mime type. I am doing this > in environment.rb: > > RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION > > require File.join(File.dirname(__FILE__), 'boot') > > #Pagination > require 'rubygems' > require 'prawn' > > Mime::Type.register "application/pdf", :pdf > > STORE_LOCATION_METHOD = :store_location > > Rails::Initializer.run do |config| > end > > require 'will_paginate' > > #Dealing with numbers > require 'bigdecimal' > require 'bigdecimal/math' > > While doing so, I tried restarting Mongrel. But, the server is failing > to start and throwing the following error: > /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:278:in > `load_missing_constant': uninitialized constant Mime (NameError) > > > Please do help! -- 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] Template-engine without rails
I would be interested in running a template engine to create output in any xml-format from Ruby/JRuby. I think using the <%..%> notation of rails would do, but I don't want this to go to the web, but rather keep it in the file system as output. Best regards Karl --~--~-~--~~~---~--~~ 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] Problem registering Mime type
I am facing problem trying to register pdf Mime type. I am doing this in environment.rb: RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION require File.join(File.dirname(__FILE__), 'boot') #Pagination require 'rubygems' require 'prawn' Mime::Type.register "application/pdf", :pdf STORE_LOCATION_METHOD = :store_location Rails::Initializer.run do |config| end require 'will_paginate' #Dealing with numbers require 'bigdecimal' require 'bigdecimal/math' While doing so, I tried restarting Mongrel. But, the server is failing to start and throwing the following error: /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:278:in `load_missing_constant': uninitialized constant Mime (NameError) Please do help! -- 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: file uploading using ajax
Use LiveQuery then you don't need rjs and responds_to_parent http://rails-revlog.blogspot.com/2009/02/ajax-sort-of-file-upload-using.html Guy Boertje --~--~-~--~~~---~--~~ 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: possibility to save data with javascript?
Frederick Cheung wrote: > On 11 Feb 2009, at 12:37, andi-hro wrote: > Well it's not rails specific at all (ie. it's just bog standard client > side stuff) but you can make an ajax request from your javascript. The > easiest way to get started would be to read up about that in whatever > javascript library you're using (prototype, jquery, mootools etc.) It's not technically accurate to say that using an AJAX request is "saving" the data from JavaScript. You would actually be "sending" the data to the server, which would then save the data from the server-side. But, it would give you access to data stored in JavaScript variables allowing you to send it to the server for processing via XMLHTTPRequest (XHR). Also note that you don't actually have to use a JavaScript framework to use XMLHTTPRequest, but the frameworks sure make things much easier, and browser independent. -- 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: ThroughAssociations
It is hard explain without example. I need Full-Text Search SELECT * FROM products WHERE MATCH(name) AGAINST('lamp') ORDER BY name Returns: "alarm lamp" "lamp" "trouble lamp" "wall lamp" But: SELECT * FROM products WHERE MATCH(name) AGAINST('lamp') ORDER BY name!='lamp', name Returns: "lamp" "alarm lamp" "trouble lamp" "wall lamp" Note difference, first result is "lamp" exactly same as search word was, and after that comes "alarm lamp" and so on.. So now we only add: catalogues.name, catalogue_items.position, products.name, products.price to results... -- 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: How to prevent users from looking at other user's data
Gerwin wrote: > Say I have Users. A user can login and create e.g. Houses..and Houses > can contain People ..etc. > > How do I prevent another logged in user from accessing another user's > House (e.g. http://test.com/houses/1 -> where id=1 doesn't belong to > this user but to another user). > > Would People also need to have a user_id field so I can check if the > request was done by the correct user? There are various ways to accomplish this but basically you want to make sure houses can only be accesses through a user. HousesController --- def index user = User.find(current_user) @houses = user.houses.find(1) ... ... end That's the basic idea anyway. -- 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: ActionView URL helper problem
James Byrne wrote: > Classes and ids for CSS are easy to produce: > > link_to "Articles", articles_path, :id => "news", :class => "article" > # => Articles > > In my code I do this: > > <%= link_to 'List All Vendors', vendors_path, :id="vendors_index" %> > and right after I posted this I saw my error = instead of =>. -- 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] ActionView URL helper problem
Rails 2.2.2 In the API it says this: Classes and ids for CSS are easy to produce: link_to "Articles", articles_path, :id => "news", :class => "article" # => Articles In my code I do this: <%= link_to 'List All Vendors', vendors_path, :id="vendors_index" %> And Rails does this: Showing app/views/entities/index.html.erb where line #108 raised: compile error /home/byrnejb/Software/Development/Projects/proforma.git/app/views/entities/index.html.erb:108: syntax error @output_buffer.concat(( link_to 'List All Vendors', vendors_path, :id="vendors_index" ).to_s); @output_buffer.concat "\n" ^ Extracted source (around line #108): 105: 106: 107: <%= link_to 'List All Clients', clients_path %> 108: <%= link_to 'List All Vendors', vendors_path, :id="vendors_index" %> 109: -- 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: ThroughAssociations
That's not any clearer - you're still just giving code examples. Like, with the two examples there, you don't say if either of them gives the results you want, and if they don't why not. This: :order => "catalogues.name!='#...@name}', catalogues.name" doesn't even make sense to me - i'm amazed that you get any result back at all from it. Say something like "I want to find all catalogues matching a given name, order them by name and then list their products" or whatever it is you're actually trying to do. -- 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] How to prevent users from looking at other user's data
Say I have Users. A user can login and create e.g. Houses..and Houses can contain People ..etc. How do I prevent another logged in user from accessing another user's House (e.g. http://test.com/houses/1 -> where id=1 doesn't belong to this user but to another user). Would People also need to have a user_id field so I can check if the request was done by the correct user? --~--~-~--~~~---~--~~ 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: validates_presence_of - only on edit
> Ok so not sure if this is possible but it would help out a lot if it > is. I am trying to put this validation on one of my forms > > validates_presence_of :name, :state > > however I only need this validation to run when they edit this form, > not when they create it. is this possible, any suggestions would be > greatly appreciated. thanks in advance. Check the docs... it's in there. # on - Specifies when this validation is active (default is :save, other options :create, :update). validates_presence_of :name, :state, :on => :update -philip --~--~-~--~~~---~--~~ 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: ActionController::RoutingError in Products#index
Hi Ashok, id's are always integer. I'm quite sure it's the same with an Oracle DB. So please fix you database and retry. ciao, tom On Feb 11, 6:19 pm, Ashok Bee wrote: > create table products ( > id number not null, > ... > primary key(id) > ) -- Thomas R. "TomK32" Koll <> http://ananasblau.com just a geek trying to change the world http://github.com/TomK32 --~--~-~--~~~---~--~~ 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] Legacy Schemas dynamic find
Hello, I'm trying to put a rails face on a legacy database. It is an old Sybase 11 database installation. I've gotten an ODBC connection working that uses unixODBC and FreeTDS to work. I'm also using the activerecord-odbc-adapter gem. I've had to use set_table_name and set_primary_key to make it work so far. However, none of the dynamic find_by methods work. I always get a method missing error. Also, find through association doesn't work as well with the same error. Normal finds on the models work, but I was hoping I can shorthand some of this. Am I SOL on this because it's a legacy DB or is there something I can do or check to make that work? If I can, that would save me some work writing find_by_sql calls. Thank 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 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] validates_presence_of - only on edit
Ok so not sure if this is possible but it would help out a lot if it is. I am trying to put this validation on one of my forms validates_presence_of :name, :state however I only need this validation to run when they edit this form, not when they create it. is this possible, any suggestions would be greatly appreciated. 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-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: ThroughAssociations
James Bond wrote: > >> Catalogue >> has_many :catalogue_items, :order => "position" > > Thanks, but if I want sot like: > > :order => "catalogues.name!='#...@name}', catalogues.name, products.name" > > Where @name is serarch word. That doesn't make sense though - you're trying to shove a search condition into the order option, and you've got all sorts of syntax errors going on. Can you explain, in english as opposed to code, what it is that you ultimately want to do? Neither of the things you've asked for have really made sense so i'm just guessing. You're asking how to do a particular bit of code but i don't think the code you're looking for is actually the code you need to do the job, if you know what i mean. -- 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: ThroughAssociations
> Can you explain, in english as opposed to code, what it is that you > ultimately want to do? Sorry. Search "way" I use is: match(catalogues.name) against "xxx" And "order by" is (catalogues.name, products.name) But first where catalogues.name == "xxx" Example If catalogues.names are: "aaa xxx", "xxx", "rrr xxx" match(catalogues.name) against "xxx" will found them all and default :order => "catalogues.name" will sort them like this: 1 "aaa xxx" 2 "rrr xxx" 3 "xxx" But if I use :order => "catalogues.name!='#...@name}', catalogues.name" order will be: 1 "xxx" 2 "aaa xxx" 3 "rrr xxx" -- 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] Importing User Libraries into Rails
Hi all, I'm using Netbeans 6.5 to develop a Rails application. I have already developed a small library to assist me in the app. It is in another project/directory. What is the best way to load this library in Rails? I have added the following to the Rails application's environment.rb: config.load_paths += %W(absolute/path/to/lib) but this doesn't seem to work. Any clues? Thanks! Shak --~--~-~--~~~---~--~~ 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: Confuse with AR association
Valentino Lun wrote: > Dear all > > Refer to http://guides.rails.info/association_basics.html > > Why :physician and :patient some with (s), and some not...? It actually > refer to the class name or table name? ** really confuse >_<. Can > someone explain it? Is it a convention of rail? Thank you. My guess is that English is not your native language. This might be why you are confused by the Rails conventions, which follows English singular/plural conventions. Here's the scoop. I hope you can follow along: First let's look at a Rails model object. The model class is like a prototype (or template) representing a single row in a database table. This is why the model class name is singular. Example: class Physician < ActiveRecord::Base ... end The database table that stores each physician contains a collection of physicians, which is why the table name is plural. Rails associations can represent either one or many model objects. Associations described as either has_one or belongs_to represent one object and therefore use the singular form: Examples: class Appointment < ActiveRecord::Base has_one :physician # This is one Physician object (singular) end class Appointment < ActiveRecord::Base belongs_to :physician # This is one Physician object (singular) end Note: Notice that has_one is used for one side of a one-to-one association. There other side would use belongs_to. Example: class Unicycle << ActiveRecord::Base has_one :wheel end class Wheel << ActiveRecord::Base belongs_to :unicycle end Associations described as has_many refer to a collection (array) of objects and therefore use the plural form: Examples: class Physician < ActiveRecord::Base has_many :appointments # This is an array of Appointment objects (plural) end I hope this makes things a little more clear to 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 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: observe_form doesn't seem to work from inside of a table
is not allowed between and or between and . It is a major inconvenience but that is the way it is. 2009/2/11 wbsurf...@yahoo.com > > > If I do observe_form as below, the ajax call never occurs, but If I > remove the table it works fine. > This is just a test to troubleshoot as I had narrowed down my problem > to this, I actually wanted a form per row of the table: > > > > > <% form_tag({:controller => 'sheet_entry', :action => > 'pass_input'}, :id => 'frmx1') do %> >hey <%= text_field_tag 'xx', 'xxx' %> > > <%= observe_form('frmx1', :url => {:action => 'ajx_form_changed'}, > :frequency => 0.5)%> > > <% end %> > > > > > > --~--~-~--~~~---~--~~ 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: ThroughAssociations
> Catalogue > has_many :catalogue_items, :order => "position" Thanks, but if I want sot like: :order => "catalogues.name!='#...@name}', catalogues.name, products.name" Where @name is serarch word. -- 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] How to show error messages in pop up or confirm screen ?
I would like to show messages when the validation fails (must be number, cant be blank, etc) but not in the main page I would like to open a pop up or better yet put it in a confirm screen where user would read and thereafter click ok. Anyone could help me ? Thanks in advance ps: sorry for bad english -- 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: Ruby on Rails: Talk | Google Groups
Have you looked at the Railscast on subdomains? http://railscasts.com/episodes/123-subdomains Eifion http://asciicasts.com Twitter: eifion On Wed, Feb 11, 2009 at 3:59 PM, Heinrich Beck wrote: > > This is more an architectural question > > I am looking to create a domain that sells widgets (as an example) > > widgets.com > > Now I have three sales reps, that each sell different kinds of > widgets, and do not need to know about each other. > > larry.widget.com > > moe.widget.com > > curley.widget.com > > I don't want to repeat myself (of course!) with the shopping cart > logic or the transactional logic. > > So, should I simply make a view for each user and then direct the > requests to the appropriate view? or is there a better way of doing > this? > > > > --~--~-~--~~~---~--~~ 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: ThroughAssociations
James Bond wrote: > There is example: > http://wiki.rubyonrails.org/rails/pages/ThroughAssociations > > Example > > Catalogue has_many :catalogue_items > CatalogueItems belongs_to :catalogue; belongs_to :product > Product has_many :catalogue_items > > So how I can get: > > catalogues.name > catalogue_items.position > products.name > products. price > WHERE > catalogues.name LIKE "xxx%" First of all, amend your association in Catalogue as follows - this will mean that the catalogue's items (and therefore products) will automatically be ordered by position. Catalogue has_many :catalogue_items, :order => "position" Then, in the controller: #do an include to eager load the relevant associations. @catalogues = Catalogue.find(:all, :conditions => ["name like ?", "#{a_variable}%"], :include => {:catalogue_items => :products}) And then, for example, in the view: <% @catalogues.each do |catalogue| %> Catalogue:<%= catalogue.name %> <% catalogue.catalogue_items.each do |item| %> <%= item.position %>: <%= item.product.name %>: <%= item.product.price %> <% end %> <% end %> Obviously you can put your own html around this, this is just a simple example. -- 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] observe_form doesn't seem to work from inside of a table
If I do observe_form as below, the ajax call never occurs, but If I remove the table it works fine. This is just a test to troubleshoot as I had narrowed down my problem to this, I actually wanted a form per row of the table: <% form_tag({:controller => 'sheet_entry', :action => 'pass_input'}, :id => 'frmx1') do %> hey <%= text_field_tag 'xx', 'xxx' %> <%= observe_form('frmx1', :url => {:action => 'ajx_form_changed'}, :frequency => 0.5)%> <% end %> --~--~-~--~~~---~--~~ 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] ActionController::RoutingError in Products#index
Env: rails 2.2.2 oracle 10g Have created a table and sequence create table products ( id number not null, title varchar2(100) not null, description varchar2(255) not null, image_url varchar2(200) not null, price number(10,2) not null, primary key(id) ) create sequence products_seq start with 1 increment by 1 nomaxvalue No errors displaying all the products using the default action index But when I put show/edit links , it errors out. Is this show link is not able to get the product id ? Please help. route.rb is good. I did look at rake route output. Error -- ActionController::RoutingError in Products#index Showing app/views/products/index.html.erb where line #17 raised: product_url failed to generate from {:action=>"show", :controller=>"products", :id=>#, title: "Laptop", description: "Laptop - TODO", image_url: "http://localhost:3000/products/new";, price: #>}, expected: {:action=>"show", :controller=>"products"}, diff: {:id=>#, title: "Laptop", description: "Laptop - TODO", image_url: "http://localhost:3000/products/new";, price: #>} Extracted source (around line #17): 14: <%=h product.description %> 15: <%=h product.image_url %> 16: <%=h product.price %> 17: <%= link_to 'Show', product %> 18: <%= link_to 'Edit', edit_product_path(product) %> 19: <%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %> 20: RAILS_ROOT: C:/Documents and Settings/beesaa/Desktop/ruby/web/depot Application Trace | Framework Trace | Full Trace C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route_set.rb:377:in `raise_named_route_error' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route_set.rb:341:in `generate' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/url_rewriter.rb:208:in `rewrite_path' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/url_rewriter.rb:187:in `rewrite_url' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/url_rewriter.rb:165:in `rewrite' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:626:in `url_for' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/url_helper.rb:85:in `send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/url_helper.rb:85:in `url_for' (eval):16:in `product_path' app/views/products/index.html.erb:17 app/views/products/index.html.erb:11:in `each' app/views/products/index.html.erb:11 app/controllers/products_controller.rb:7:in `index' -- 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: Confuse with AR association
It is the convention in Rails A Physician (singular) has many appointments (plural) An Appointment (singular) belongs to one patient (singular) 2009/2/11 Valentino Lun > > Dear all > > Refer to http://guides.rails.info/association_basics.html > > Why :physician and :patient some with (s), and some not...? It actually > refer to the class name or table name? ** really confuse >_<. Can > someone explain it? Is it a convention of rail? Thank you. > > class Physician < ActiveRecord::Base > has_many :appointments > has_many :patients, :through => :appointments > end > > class Appointment < ActiveRecord::Base > belongs_to :physician > belongs_to :patient > end > > class Patient < ActiveRecord::Base > has_many :appointments > has_many :physicians, :through => :appointments > end > > Many thanks > Valentino > -- > 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] ThroughAssociations
There is example: http://wiki.rubyonrails.org/rails/pages/ThroughAssociations Example Catalogue has_many :catalogue_items CatalogueItems belongs_to :catalogue; belongs_to :product Product has_many :catalogue_items So how I can get: catalogues.name catalogue_items.position products.name products. price WHERE catalogues.name LIKE "xxx%" -- 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] Confuse with AR association
Dear all Refer to http://guides.rails.info/association_basics.html Why :physician and :patient some with (s), and some not...? It actually refer to the class name or table name? ** really confuse >_<. Can someone explain it? Is it a convention of rail? Thank you. class Physician < ActiveRecord::Base has_many :appointments has_many :patients, :through => :appointments end class Appointment < ActiveRecord::Base belongs_to :physician belongs_to :patient end class Patient < ActiveRecord::Base has_many :appointments has_many :physicians, :through => :appointments end Many thanks Valentino -- 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] Ruby on Rails: Talk | Google Groups
This is more an architectural question I am looking to create a domain that sells widgets (as an example) widgets.com Now I have three sales reps, that each sell different kinds of widgets, and do not need to know about each other. larry.widget.com moe.widget.com curley.widget.com I don't want to repeat myself (of course!) with the shopping cart logic or the transactional logic. So, should I simply make a view for each user and then direct the requests to the appropriate view? or is there a better way of doing this? --~--~-~--~~~---~--~~ 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: what does config.threadsafe! actually do?
Aaron Baldwin wrote: > There is some good information right in the rails 2.2 release notes > along with links to blogs with more information. > http://guides.rubyonrails.org/2_2_release_notes.html#_thread_safety Thanks Aaron. I definitely checked that out before posting, but it (and it's links) don't have quite enough information for me. They don't really say what config.threadsafe! _does_, except for allow concurrent request handling. Guess I'll have to dive into the source at some point. -- 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] Can replace_html change the value of an input text?
Hello, I'm updating one area with one partial, using a page of .js.rjs, and the code: page.replace_html("div_list", :partial => "list", :object => @expedients) Also, I would like to empty the field value that I use to send the Ajax request, but I can't make it to work, maybe it's not possible with page.replace ... seudo code: page.replace_html("expedient_reference", :partial => "blank",) Basically I want to change the value of the id expedient_reference: Referencia is this possible ? thanks, r. -- 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: Active Record Associations
Why is a good question here. In other words, what are you going to do with the computers and users once You get them. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 11/02/2009, at 4:42 AM, James Bond wrote: > > Rey wrote: >> If I understand correctly what you need, a computer may belong to >> many >> users and one user can have many computer, right? same for phones, I >> assume. > > Yes > >> In this case, the relationship is :has_and_belongs_to_many, but you >> do > > How can I find all users whose name is "James%" and their computers > (not > mobiles)? > > User.find(:all, ??) > -- > 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: templating-like system recommendations?
Phil Smy wrote: > No one is doing user-editable html pages? Hi Phil, There is liquid: http://www.liquidmarkup.org/ It is not pure HTML but allows user-editing of pages. It is used in the shopify product offering. I have never used it, however, the developers of it are well known and top notch folks. It may not be exactly what you're looking for, but food for thought. Thanks, Rick -- 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] ActiveRecord ssl Postgres connections
Hello All, I'm looking to see if I can coerce ActiveRecord to connect to a remote Postgres server via ssl. Htere seems to be a way to do it with MySQL, but I don't see similar capability in the Postgres Adapter. Has anyone been able to force ActiveRecord to use SSL to connect to a remote Postgres server? Any help would be appreciated because I'm stuck. Mike --~--~-~--~~~---~--~~ 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: Active Record Associations
Oh by the way if you do that you'll end up with an array of arrays. Might not be what you want. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 11/02/2009, at 11:50 PM, Sijo Kg wrote: > > Hi > > @users = User.find(:all,:conditions=> ['name LIKE ?', "James%"]) > @user_computers = [] > @users.each do |user| > @user_computers << user.computers > end > > @user_computers now contains computers you need > > > Sijo > -- > 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: Active Record Associations
Or use has_many :through instead. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 11/02/2009, at 11:50 PM, Sijo Kg wrote: > > Hi > > @users = User.find(:all,:conditions=> ['name LIKE ?', "James%"]) > @user_computers = [] > @users.each do |user| > @user_computers << user.computers > end > > @user_computers now contains computers you need > > > Sijo > -- > 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: Active Record Associations
Sijo Kg wrote: I mean something like this: SELECT users.name, computers.name FROM users, OwnComputers, computers JOIN OwnComputers ON users.id = OwnComputers.users_id JOIN computers ON OwnComputers.computers_id = computers.id WHERE user.name LIKE "James%" -- 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] XML::Parser#string is deprecated : Getting too many warnings
Hi , I am doing XML parsing to get data from xml documents inside a Rails project. I get my job done but there are too many warnings in between.I dont understand how can i avoid this. the error warnings are : warning: Passing no parameters to XML::Parser.new is deprecated. Pass an instance of XML::Parser::Context instead. XML::Parser#string is deprecated. Use XML::Parser.string instead I am using Libxml for parsing.Can anyone please provide some help in this regards? -- 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: possibility to save data with javascript?
On 11 Feb 2009, at 12:37, andi-hro wrote: > > hey, > > is in ruby on rails possibility to save data with javascript? > > for example to call a controller/action with parameters from a > javascript? > Well it's not rails specific at all (ie. it's just bog standard client side stuff) but you can make an ajax request from your javascript. The easiest way to get started would be to read up about that in whatever javascript library you're using (prototype, jquery, mootools etc.) Fred > thank you. > > andi > > > --~--~-~--~~~---~--~~ 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] possibility to save data with javascript?
hey, is in ruby on rails possibility to save data with javascript? for example to call a controller/action with parameters from a javascript? thank you. andi --~--~-~--~~~---~--~~ 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: Active Record Associations
Hi @users = User.find(:all,:conditions=> ['name LIKE ?', "James%"]) @user_computers = [] @users.each do |user| @user_computers << user.computers end @user_computers now contains computers you need Sijo -- 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] How to add Bookmarks in Ruby on Rails
I want to add few bookmarks from a page which will link to other titles on a homepage. Thank you in advance for your help. -- 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: Refactoring RJS
On 11 Feb 2009, at 10:41, David wrote: > > I have some RJS that could use some refactoring. I use the function > called with afterFinish twice and Im wondering what the best way to > refactor is. This is all inline rjs in the controller mind you: > > page.visual_effect :slide_down, "add_appt_#{params > [:day]}", :afterFinish => "function(){ > $('end_drop_#{params[:day]}_#{params > [:appt_counter]}').style.display = 'block'; > $('end_drop_#{params[:day]}_#{params > [:appt_counter]}').style.visibility = 'hidden'; > $('start_drop_#{params[:day]}_#{params > [:appt_counter]}').style.display = 'block'; > $('start_drop_#{params[:day]}_#{params > [:appt_counter]}').style.visibility = 'hidden'; > }" Yummy :-). if you're using prototype you can replace $('end_drop_foo').style.display = 'block'; $('end_drop_foo').style.visibility = 'hidden'; with $('end_drop_foo').setStyle({display: 'block', visibility: 'hidden'}) If i were you I'd have in my application.js a function like function resetVisibility(element){ element.setStyle({display: 'block', visibility: 'hidden'}) } then then your rjs stuff looks like resetVisibility('end_drop_#{params[:day]}_#{params[:appt_counter]}') resetVisibility('start_drop_#{params[:day]}_#{params[:appt_counter]}') or even right the whole thing as a js function (RJS can be a bit of a crutch) 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: general iplementation question Do I need polymorphic her
I shal explain more. I have say three tabs like Organization PrimaryContact OtherContacts And each tab contains there own information and at bottom a common save button there.When clicking on that what happens is a new Request is created and it has to associate and save with the above data..But here I dont know how to form the tables and the relations and also in REST way Please help -- 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: Sessions do not update created_at column?
On 11 Feb 2009, at 10:21, Mathieu Rousseau wrote: > With default AR it always did this for me automatically... Frederick > said something about using a different flavour of AR, but that's > beyond my knowledge... > To expand on what I said, when you use active_record_store you provide a session class that handles the loading and saving of the data (as opposed to the other bits of a session store). Rails provides an implementation which is just a plain old model class but you can replace that with one that just issues raw sql statements (mostly in the interest of speed). An example one is included with rails. Obviously if you didn't know any of that you probably haven;'t done that :-) In the absence of all that created_at and updated_at should update automatically as it is just a regular ActiveRecord class. Dumb question: did you restart your mongrel or whatever is handling your requests after you added that column ? Fred > On Wed, Feb 11, 2009 at 8:17 AM, Arthur Chan > > wrote: > > Yes. > > The problem is that the field has not been filled at any time... > > I just want both "created_at" and "updated_at" be filled in > automatically. > > > Mathieu Rousseau wrote: > > Created_at is supposed to be filled only at creation time, right? > > Shouldn't > > you use updated_at instead? > > > > On Wed, Feb 11, 2009 at 7:31 AM, Arthur Chan < > > -- > 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: templating-like system recommendations?
No one is doing user-editable html pages? On Feb 10, 10:24 am, phil wrote: > Hi, > We want to add a significant new feature into our inhouse RoR system - > we want to let admins create web pages that display data pulled from > our database. > We (I think) have figured out how to give them the data, but, where I > would love some advice is on how to give them a robust ability to > create the pages. Is using something like Liquid the way to go? They > would need to be able to enter full html (or a language that gives you > full control over the html) in addition to being able to place values > from the data. > Has anyone done something like this? Does anyone have any > recommendations for plugins, etc that would make writing such a system > a bit easier? > > Any help would be greatly appreciated. > > Thanks! > > Phil --~--~-~--~~~---~--~~ 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: How to install Rails on CentOS 5.2
Ok, Here is what I have to prep the box - this may not apply as it depends on your install, but maybe you can look through here and see. PREP THE SYSTEM: 0) As root: rpm -i http://ftp.gui.uva.es/sites/centos.org/4.6/os/i386/CentOS/RPMS/python-elementtree-1.2.6-5.el4.centos.i386.rpm rpm -i http://ftp.gui.uva.es/sites/centos.org/4.6/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm rpm -i http://ftp.gui.uva.es/sites/centos.org/4.6/os/i386/CentOS/RPMS/sqlite-devel-3.3.6-2.i386.rpm rpm -i http://ftp.gui.uva.es/sites/centos.org/4.6/os/i386/CentOS/RPMS/python-sqlite-1.1.7-1.2.1.i386.rpm rpm -i http://ftp.gui.uva.es/sites/centos.org/4.6/os/i386/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpm rpm -i http://ftp.gui.uva.es/sites/centos.org/4.6/os/i386/CentOS/RPMS/yum-metadata-parser-1.0-8.el4.centos.i386.rpm rpm -i http://ftp.gui.uva.es/sites/centos.org/4.6/os/i386/CentOS/RPMS/yum-2.4.3-4.el4.centos.noarch.rpm rpm -Uvh http://ftp.gui.uva.es/sites/centos.org/4.6/os/i386/CentOS/RPMS/centos-release-4-4.4.i386.rpm rpm --import http://mirror.centos.org/centos-4/4.6/os/i386/RPM-GPG-KEY-centos4 1) install gcc sudo yum install -y gcc 2) install wget sudo yum install -y wget 3) install various other things that came up! sudo yum install -y fedora-rpmdevtools -- not found/needed sudo yum install -y openssl-devel sudo yum install -y zlib zlib-devel sudo yum install -y libjpeg-devel libpng-devel glib2-devel fontconfig- devel zlib-devel libwmf-devel freetype-devel libtiff-devel sudo yum install -y cabextract -- not found sudo yum install -y pcre-devel sudo yum install -y subversion sudo yum install -y readline-devel 4) Create a file in $HOME called .rpmmacros with the following line in it %_topdir %(echo $HOME)/rpmbuild create the directories $HOME/rpmbuild/BUILD and $HOME/rpmbuild/RPMS/ noarch 5) cabextract wget http://centos.karan.org/el4/extras/stable/i386/RPMS/cabextract-1.1-2.i386.rpm sudo rpm -ihv cabextract-1.1-2.i386.rpm 6) get ssh keys in place http://homepage.mac.com/kelleherk/iblog/C1901548470/E20061128145420/index.html On Feb 11, 7:14 am, Paryank wrote: > Thanks phil, > > But I still have the same error. > > I have removed my existing ruby package by: > > yum remove ruby > > And then followed the steps you have mentioned. But when I run command > to install rails first it try to update rubygems. It was taking very > long time. So I have updated rubygems by the following command: > > gem update --system > > After gem is successfully updated, I tried again to install rails. But > it was giving the same error again: > > ERROR: While executing gem ... (Zlib::DataError) > incorrect header check > > On Feb 10, 3:23 pm, phil wrote: > > > Here is what I have - it may be a little old now - from notes to get > > our CentOS sever running. > > > INSTALLING RUBY ON RAILS: > > = > > 1) Install Ruby > > > See:http://rubyonrails.org/down > > > wgethttp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz > > tar -zxvf ruby-1.8.6.tar.gz > > cd ruby-1.8.6 > > ./configure --with-openssl-dir=/usr/lib/openssl > > make > > sudo make install > > > These MAY not be needed. Come back and do them if things don't go > > right in install ruby gems and rails. > > 1a) zlib support > > cd ruby-1.8.6 > > ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/ > > lib > > make > > sudo make install > > > 1b) openssl > > cd ruby-1.8.6/ext/openssl > > ruby extconf.rb > > make > > sudo make install > > > 2) Install ruby gems > > wgethttp://rubyforge.org/frs/download.php/28174/rubygems-0.9.5.tgz > > tar -zxvf rubygems-0.9.5.tgz > > cd rubygems-0.9.5 > > sudo ruby setup.rb config > > sudo ruby setup.rb setup > > sudo ruby setup.rb install > > > 3) Install Rails: > > sudo gem install --version '2.1.0' rails --include-dependencies > > > 4) Install Mongrel > > sudo gem install mongrel mongrel_cluster > > > On Feb 10, 11:14 am, Paryank wrote: > > > > Thanks for your help. But it still does not work. > > > > I have downloaded ruby source, compiled and installed. It still gives > > > the same error! > > > > I do not understand what I am missing! > > > > On Feb 10, 11:51 am, Xie Hanjian wrote: > > > > > Hi Paryank, > > > > > Though I have no direct solution for you, I think compile/install Ruby > > > > 1.8.7 may solve this problem, while ruby packages on CentOS is obsolete. > > > > > Jan > > > > > * Paryank [2009-02-09 21:29:44 -0800]: > > > > > > Hi > > > > > > I have installed CentOS 5.2 on my PC. Ruby 1.8.5 and Ruby-devel > > > > > packages are already installed. I have downloaded rubygems-1.3.1.tgz > > > > > package and installed it. Now I am trying to install Rails by the > > > > > command below: > > > > > > gem install rails > > > > > > But it gives me the following error: > > > > > > ERROR: While executing gem ... (Zlib::DataError) > > > > > incorrect header check > > > > > > zlib and zlib-devel are already installed on my pc. I can install > > > > > other gems like hprico
[Rails] Re: insert rails into php
On 11 Feb 2009, at 10:37, Sniper Abandon wrote: > > hi experts, > > i have a PHP web application which consists of so much modules (like > registration,billing,reports,etc...) > > i want to convert arround only 60% modules from PHP to Rails, that > means > remaining 40% modules should be in PHP only. > > i thing my webserver should be a bridge between rails & PHP > application > > > is there any webserver which can check the request url and send the > request to rails or PHP accordingly ? > apache, nginx etc... can certainly forward the request to different places based on the url (and other things). Where things might get complicated is to what extent your php bits and your rails bits will need to share information 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] remote_form_for file_field strangeness
Does anyone see any problem with this form? - form_remote_for(Photo.new, :html => {:multipart => true, :target => :uploader}) do |f| .form_element = f.label :photo = f.file_field :collateral = hidden_field_tag :container_id, @shoot.id = hidden_field_tag :container_type, @shoot.class.name .form_element = f.submit 'Add Photos' The photo has a paperclip attachment called collateral, and a double polymorphic relation with container (which can be a shoot, model or photographer). At the bottom of the page is an iframe with the id and name 'uploader'. However, when submitted via AJAX, it never serializes the file_field: both the development log and firebug both only show the hidden params being passed. It works fine as a form_for, however. I'm using 2.2.2 on OSX 10.5.6 and the responds_to_parent plugin to, well, respond. Thanks, Todd --~--~-~--~~~---~--~~ 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] Sending explicit js to browser from RJS
I am using jQuery with the rails defaults in my app and would like to call jQuery commands from my RJS templates or from respond_to blocks. I've seen this used in a railscast: page << "jQuery('some_id').css('color','red');" but I'd like it to execute with the others, namely: page.visual_effect :highlight, 'some_id' page << "jQuery('some_id').css('color','red');" Am I going about this the wrong way, or should this be working? -- 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: db:migrate and Mysql error
Discovered the solution elsewhere and thanks to fred who provide enough of an addition clue to hunt down other oblique references to the problem: The problem is that libmysql.dll shipped with Mysql 5.1 doesn't play well with ruby 2.2.. The solution is to download the libmysql.dll from: http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll and save this in your ruby bin directory see also: http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407 On Feb 9, 9:50 pm, Frederick Cheung wrote: > On Feb 9, 10:11 am, "bflo...@westpac.com.au" > wrote: > > > I have read relevant posts regarding versions ofmysqland > > libmysql.dll which I have taken action on. > > I would appreciate any clues as it is driving me nuts %). > > > I am using: > > MS Windows XP Home Ediition Version 2002 SP3 > > ruby ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32] > > rails 2.2.2 > > mysqlgem 2.7.3 > > Mysql5.1.31-community > > I recall vaguely seeing messages about this previously with the end > result being thatmysql5.1.x was the problem. > > Fred > > > Cheers > > Barry > > > The trace is as follows: > > C:\rails\photos>C:\rails\photos>rake db:migrate --trace > > (in C:/rails/photos) > > ** Invoke db:migrate (first_time) > > ** Invoke environment (first_time) > > ** Execute environment > > ** Execute db:migrate > > rake aborted! > > undefined method `each' for # > > C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > > connection_adapters/mysql_adapter.rb:414:in `tables' > > C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > > connection_adapters/abstract/schema_statements.rb:330:in > > `initialize_schema_migrations_table' > > C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > > migration.rb:430:in `initialize' > > C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > > migration.rb:394:in `new' > > C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > > migration.rb:394:in `up' > > C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > > migration.rb:377:in `migrate' > > C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake: > > 111 > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in > > `invoke_with_call_chain' > > C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in > > `invoke_with_call_chain' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in > > `invoke_task' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in > > `top_level' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in > > `top_level' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in > > `standard_exception_handling' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in > > `top_level' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in > > `standard_exception_handling' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run' > > C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31 > > C:/Ruby/bin/rake:19:in `load' > > C:/Ruby/bin/rake:19 --~--~-~--~~~---~--~~ 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] Refactoring RJS
I have some RJS that could use some refactoring. I use the function called with afterFinish twice and Im wondering what the best way to refactor is. This is all inline rjs in the controller mind you: page.visual_effect :slide_down, "add_appt_#{params [:day]}", :afterFinish => "function(){ $('end_drop_#{params[:day]}_#{params [:appt_counter]}').style.display = 'block'; $('end_drop_#{params[:day]}_#{params [:appt_counter]}').style.visibility = 'hidden'; $('start_drop_#{params[:day]}_#{params [:appt_counter]}').style.display = 'block'; $('start_drop_#{params[:day]}_#{params [:appt_counter]}').style.visibility = 'hidden'; }" --~--~-~--~~~---~--~~ 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] insert rails into php
hi experts, i have a PHP web application which consists of so much modules (like registration,billing,reports,etc...) i want to convert arround only 60% modules from PHP to Rails, that means remaining 40% modules should be in PHP only. i thing my webserver should be a bridge between rails & PHP application is there any webserver which can check the request url and send the request to rails or PHP accordingly ? any other idea & help appreciated . thx -- 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: NB 6.5, OS/X, Rails Gem Version error
well. Do as the error tells you to You need to install a specific version of rails...version 2.1.1 This is done by: gem install -v=2.1.1 rails :-) On Feb 11, 2:05 am, Elmo wrote: > I am getting the following error message when I attempt to start > WEBRick: > > Missing the Rails 2.1.1 gem. Please `gem install -v=2.1.1 rails`, > update your RAILS_GEM_VERSION setting in config/environment.rb for the > Rails version you do have installed, or comment out RAILS_GEM_VERSION > to use the latest version installed. > > I tried commenting out the RAILS_GEM_VERSION and it doesn't do > _anything_ at all. The problem is that I can start the application via > the command line just fine. I am not using jRuby, but instead compiled > and installed my own version of Ruby, Gem, and Rails into /usr/local/ > and am using that pathing for all the tools (at least on commandline - > I don't know if Netbeans is ignoring the PATH). > > On my Linux box the same source tree works fine and runs WEBRick. I > saw the following message in this google group, BUT where is ruby2/ > rake_tasks_info.rb I only have an executable file on the > Mac:http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/... --~--~-~--~~~---~--~~ 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: Sessions do not update created_at column?
With default AR it always did this for me automatically... Frederick said something about using a different flavour of AR, but that's beyond my knowledge... On Wed, Feb 11, 2009 at 8:17 AM, Arthur Chan < rails-mailing-l...@andreas-s.net> wrote: > > Yes. > > The problem is that the field has not been filled at any time... > > I just want both "created_at" and "updated_at" be filled in > automatically. > > > Mathieu Rousseau wrote: > > Created_at is supposed to be filled only at creation time, right? > > Shouldn't > > you use updated_at instead? > > > > On Wed, Feb 11, 2009 at 7:31 AM, Arthur Chan < > > -- > 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: Sessions do not update created_at column?
Yes. The problem is that the field has not been filled at any time... I just want both "created_at" and "updated_at" be filled in automatically. Mathieu Rousseau wrote: > Created_at is supposed to be filled only at creation time, right? > Shouldn't > you use updated_at instead? > > On Wed, Feb 11, 2009 at 7:31 AM, Arthur Chan < -- 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] Expiring cache from a rake task
Hello, I have a question on cache expiration only working from the web, and not from the console or from a rake task. I have 2 models, Post e Comments. I have this page /archives where I list all old posts. I created a controller 'archives', where I have a page cache (caches_page :index). I need to expire this page cache, every time a Post or Comment is created/updated/destroyed. Using sweepers, this works 100%. ( http://www.railsenvy.com/2007/2/28/rails-caching-tutorial#sweepers) The problem is that, now, I implemented spam moderation by Akismet. So when a new comment is created in the database, it gets a 'pending' status. And there's a rake task that runs every x minutes, in order to check all 'pending' comments against the Akismet database, and only then comments earn an 'approved' or 'spam' status. And it's only then that I should expire the /archives page. So I need to expire a cached page, from something that happens outsite a controller. And it seems the only situation a sweeper works is when the event is triggered by the web. If I open the console, add a new comment to a post, nothing happens (ok!). And now I run the Akismet check, and assuming it gives the comment an 'approved' status, the cache is not expired, when it should be. I tried to use Observers, from the Rails docs ( http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M001871&name=observe ). In environment.rb I added the line: config.active_record.observers = :archives_observer I created the file app/models/archives_observer.rb with: class ArchivesObserver < ActiveRecord::Observer observe :post, :comment def after_save(record) expire_page(:controller => 'archives', :action => 'index') end end But I get an error: NoMethodError: undefined method `expire_page' for # I tried this also: class ArchivesObserver < ActionController::Caching::Sweeper (...) In this case, there's no error, and it does nothing at all. The public/archives.html just stays there. I'm trying my best to avoid hacking it, using a simple File.delete :) Like the code below: # File rails/actionpack/lib/action_controller/caching/pages.rb, line 65 65: def expire_page(path) 66: return unless perform_caching 67: 68: benchmark "Expired page: #{page_cache_file(path)}" do 69: File.delete(page_cache_path(path)) if File.exist?(page_cache_path(path)) 70: end 71: end Is there a way to expire pages without having to hack it? Thanks a lot, Levy --~--~-~--~~~---~--~~ 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: Sessions do not update created_at column?
Created_at is supposed to be filled only at creation time, right? Shouldn't you use updated_at instead? On Wed, Feb 11, 2009 at 7:31 AM, Arthur Chan < rails-mailing-l...@andreas-s.net> wrote: > > Hi All, > > I added a column to the sessions table called "created_at" in order to > allow the created time to be recorded. > > However, different from other Models, the column does not update > automatically. > > Therefore, what codes should I add to update the sessions."created_at" > value? > > It is important for avoiding hacker keeping the sessions alive. > > Thanks much! > Arthur > -- > 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: Initialize database connection when my rails project start
hi Fred, Thank you for your reply. I just load the script in config/initializers and make the conn_pool to @conn_pool. It work fine. But I want to learn more. Could you further elaborate on this, how can I do this in Server Class?? I have really no ideas..(I am a not really experienced in rails) > Failing that I;d have the conn_pool thingy be an instance variable of > the Server class with an accessor (so you could do Server.conn_pool > [...]). This all looks a little strange though. Thanks again Valentino -- 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] page.replace_html and
Hello, I have a page with a form and a div area that I update after submitting the form. I want to replace the Div area with new information. In the page, inside the div area, I have: <%= render :partial => "list" %> as I want to show the current records the first time the page opens. The problem is after submitting, I the 'old values' of the Div remain in the Div, and now I have the new values with the old values. If I continue to add some new values, I get always on top the new ones and after the 'old ones', I get TWO tables, the new one and the old one. How I can remove the old table If for example I add some text on the top of the _list (partial included in the Div), this text gets removed but NOT the table. Any ideas ? I'm updating the div with a .js.rjs file: page.replace_html("div_listd", :partial => "list") If in the page I don't put the <%= render :partial => "list" %>, I don't see the inital records (correct), and subsequent forms submitted show the resulted records ok, so the .js can replace the content of the Div area ... very strange for me ... thanks, r. -- 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: Write checkbox values in database
Hi Aaron, Thanks for your precious time. I tried your suggestion too. I think i am doing some relationship mistake between models. I am not sure whether i am doing it in the right way. I will try to explain what i have done. Kindly give me whether i am right or whether i am on the wrong way. I have a models called Child.rb, Childcategory.rb and Filtercategory.rb The relationships are as given below class Child < ActiveRecord::Base belongs_to :user has_many :childcategories has_many :timelimits end class Childcategory < ActiveRecord::Base has_and_belongs_to_many :filtercategories end class Filtercategory < ActiveRecord::Base end NOw i have list of category names in Filtercategories table. I am listing them using checkboxes in the child view and trying to write them in Childcategories table if checked by the user. i.e. app/views/children/show.html.erb <% remote_form_for [...@child, Childcategory.new] do |f| %> <%= f.label :body, " Allowed Categories " %> <% for category in @cat %> <%= check_box_tag 'child_category[category_ids][]', category.id %> <%= category.categoryname %> <% end %> <%= f.submit "Update Settings" %> <% end %> The controller of Childcategories is as below. class ChildcategoriesController < ApplicationController def create @child = Child.find(params[:child_id]) @catlist = @child.childcategories.create!(params[:childcategory]) respond_to do |format| format.html { redirect_to @child } format.js end end end Hence i have written the code in this manner. But the table is not updated with categories checked by the user. Only childid is inserted and new record is created without category name and id. Kindly help me in this regard.It will be very supportive. Thanks for any help, Swarna -- 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: HABTM & pagination confused
Thanks bro got the solutions @students = Seminar.find(params[:id]).students.paginate (:page => params[:page], :per_page => 10) On Wed, Feb 11, 2009 at 1:35 PM, MaD wrote: > > > > Caveat: I am a noobie to Rails .. just trying to help. > > but still, you're right. mislav-will_paginate is the way to go. > > > --~--~-~--~~~---~--~~ 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: Sessions do not update created_at column?
Hi Fred, Do you mean? config.action_controller.session_store = :active_record_store I am setting up as the above. Does it mean that I should have the function? Thanks Arthur Frederick Cheung wrote: > On Feb 11, 9:31�am, Arthur Chan > wrote: >> Hi All, >> >> I added a column to the sessions table called "created_at" in order to >> allow the created time to be recorded. >> >> However, different from other Models, the column does not update >> automatically. >> > What flavour of active record store do you use ? Some people use ones > which mostly bypass activerecord (and as a result you don't get some > of the stuff AR gives you for free), > > Fred -- 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: Sessions do not update created_at column?
On Feb 11, 9:31 am, Arthur Chan wrote: > Hi All, > > I added a column to the sessions table called "created_at" in order to > allow the created time to be recorded. > > However, different from other Models, the column does not update > automatically. > What flavour of active record store do you use ? Some people use ones which mostly bypass activerecord (and as a result you don't get some of the stuff AR gives you for free), Fred > Therefore, what codes should I add to update the sessions."created_at" > value? > > It is important for avoiding hacker keeping the sessions alive. > > Thanks much! > Arthur > -- > 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] Sessions do not update created_at column?
Hi All, I added a column to the sessions table called "created_at" in order to allow the created time to be recorded. However, different from other Models, the column does not update automatically. Therefore, what codes should I add to update the sessions."created_at" value? It is important for avoiding hacker keeping the sessions alive. Thanks much! Arthur -- 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: Initialize database connection when my rails project start
On Feb 11, 9:03 am, Valentino Lun wrote: > Dear all > > I have the following ruby code that can establish multiple(around 300) > database connection and stored them in a hash (conn_pool). > > I can use conn_pool["Keys"].connection.execute("select * from table") to > get the SQL result. Why not just do "Keys".constantize (will will return the Keys class) , ie foo.constantize.connection.execute 'bla bla bla" since it seems that the objects in your hash are just the corresponding ActiveRecord classes ? Failing that I;d have the conn_pool thingy be an instance variable of the Server class with an accessor (so you could do Server.conn_pool [...]). This all looks a little strange though. Fred > > My question is that, how can I initialize these database connections > when my rails project started? So I can access conn_pool[something] in > controllers. > > Please give me some advices. > > Thank you very much > > Valentino > > require 'rubygems' > require 'resolv' > require 'activerecord' > > class LIS_SSC_ST1 < ActiveRecord::Base > end > > LIS_SSC_ST1.establish_connection( > :host => "localhost", > :adapter => "jdbc", > :dialect => "sybase", > :autocommit => false, > :driver => "com.sybase.jdbc3.jdbc.SybDataSource", > :url => "jdbc:sybase:Tds:cdcibm74.server.ha.org.hk:22601/SSC_DB", > :username => "username", > :password => "password") > > class Server < LIS_SSC_ST1 > set_table_name "ssc_servers" > end > > r = Regexp.new("LIS_..._SP(1[012])") > conn_pool = {} > > def is_active?(dns,host) > Resolv.getaddress(dns) == Resolv.getaddress(host) ? true : false > end > > def make_conn(h,server_name) > eval("class #{server_name} < ActiveRecord::Base > end") > eval(server_name).establish_connection(h) > end > > Server.find(:all, :conditions => "server_type = 'sybase'", :order => > "server_name").each do |x| > if x.server_name =~ r > server_name = x.server_name.gsub("SP","ST") > server_dns = x.server_name.gsub("_SB","").gsub("_","-").downcase > if is_active?(server_dns,x.server_host) > h = {:host => "localhost", > :adapter => "jdbc", > :dialect => "sybase", > :autocommit => false, > :driver => "com.sybase.jdbc3.jdbc.SybDataSource", > :url => > "jdbc:sybase:Tds:#{server_dns}:#{x.port.to_s.gsub(/^4/,"2")}/LAB_DB", > :username => "username", > :password => "password"} > > conn_pool[server_name] = make_conn(h,server_name) > end > end > end > -- > 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] form_remote_tag and doesn't pass params ?
Hello, This code works as expected: <% form_remote_tag(:url => {:action => 'create_ajax'}) do %> Referencia <%= text_field 'expedient', 'reference' %> <%= submit_tag 'Send Email' %> <% end %> Processing ExpedientsController#create_ajax (for 127.0.0.1 at 2009-02-11 10:21:15) [POST] Session ID: d0862b3026b383198421acc44e03749c Parameters: {"expedient"=>{"reference"=>"1234"}, "commit"=>"Send Email", "authenticity_token"=>"fee980baf3cb7450236dd32e8a25dd0f0eb3911f"} But, if I want to add a ... for the input fields, RoR doesn't receive the params, this code doesn't work: <% form_remote_tag(:url => {:action => 'create_ajax'}) do %> referencia<%= text_field 'expedient', 'reference' %><%= submit_tag 'Send Email' %> <% end %> Processing ExpedientsController#create_ajax (for 127.0.0.1 at 2009-02-11 10:21:55) [POST] Session ID: d0862b3026b383198421acc44e03749c Parameters: {"commit"=>"Send Email", "authenticity_token"=>"fee980baf3cb7450236dd32e8a25dd0f0eb3911f"} I can't see any strange code in the source html resultant page ... any ideas ? thanks! r. -- 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] Vim on Rails
Is there any group focused on usage of Vim on Ruby on Rails development? Possibly an emailing list (Google Group)? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---