[Rails] Re: Newbie regular expression question..
AMILIN Aurélien wrote: Le 07/04/2010 11:44, Hemant Bhargava a �crit : Hello champs, I am having an string and i want all extra characters to be removed from that string except + and . How to write a regular expression for it.. Currently i am trying it like this as word.sub(/[_-\:\\\/]/, ).. But its not working.. I can do it like this as well:- word.sub(/[\W]/, ) but this will replace all characters even also + and . This seems to be what you need : str = ABCD EF + (GH_IJ).klm _ ^^z str.gsub(/[^\w\+\.]|\_/i, '') = ABCDEF+GHIJ.klmz -- Aur�lien AMILIN Thanks guyz, this worked like a charm.. Thanks to all of you who replies so quickly .. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] incompatible character encodings: ASCII-8BIT and UTF-8
I am getting an error incompatible character encodings: ASCII-8BIT and UTF-8 when I try to render a partial view for the children objects of a main object's edit page. This is the controller method : def update @display_treatment = [ {exam type=treatmenttype} , {preparation comments=preparation}, {preparation nature=natureprep} , {reference cut=refCoupe}, {author=author}, ] @echantillon = Echantillon.find(params[:id]) @treatments = Treatment.find(:all, :conditions = ['echantillon_id = ?', @echantillon.id]) respond_to do |format| if @echantillon.update_attributes(params[:echantillon]) flash[:notice] = 'Echantillon was successfully updated.' format.html { redirect_to(@echantillon) } format.xml { head :ok } else format.html { render :action = edit } format.xml { render :xml = @echantillon.errors, :status = :unprocessable_entity } end end end and this is in the edit view: %= render :partial = 'treatmentupdate', :locals = {:treatments = @echantillon.treatments} % and this is the partial: % @i = 1 % % for treatment in @treatments % trtd colspan=2h2Traitement %= @i % /h2/td/tr % fields_for echantillon[treatment_attributes_updates][], treatment do |treatment_form|% % for c in @display_treatment % tr td class =name %= c.first.first % : /tdtd/tdtd%= text_field :treatment, c.first.second, :value = treatment[c.first.second] %/td td/td /tr % end % trtd colspan=3hr//td/tr % end % % @i = @i + 1 % % end % I am getting the error on this line: td class =name %= c.first.first % : /tdtd/tdtd%= text_field :treatment, c.first.second, :value = treatment[c.first.second] %/td -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Jobs: 2x Ruby on Rails Developer – Dot Com Start-up, London
Position still open. paul.dan...@hamiltonblake.co.uk -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: weird dates problem
sory for the long absence (holidays) well the params[:to] is a date in this format 27.02.2010, but when i try to log params[:to].to_date I get an error NoMethodError( undefined method'[]' for nil:NilClass) On 1 Kwi, 07:50, Colin Law clan...@googlemail.com wrote: On 1 April 2010 15:36, Adam anlauf.a...@gmail.com wrote: HI, I have a pretty weird problems withdates. my objective was to parse some text files and put them into a database. the lines of the file are divided with a | and some of the fields are datesin this format dd.mm. now in the parsing a get the system date to skip parsing elements in the past @date is the local date created with �...@date = Time.now.to_date params[:to] is the string from the file with the date in above format I did this with a simple if params ( params[:to].to_date @date ) # nie parsujemy starych cennikow Price.create_or_update params end on my local enviroment everything works fine but on the remote host i get an invalid date ArgumentError Catch the error in your code and log or display the params[:to] that is causing it. Then you will likely see the problem. It is risky to convert strings to date without checking validity and taking appropriate action anyway. Colin ruby version on host ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-linux] local ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux] any ideas? thanks in advance -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: weird dates problem
Le 07/04/2010 12:41, Adam a écrit : sory for the long absence (holidays) well the params[:to] is a date in this format 27.02.2010, but when i try to log params[:to].to_date I get an error NoMethodError( undefined method'[]' for nil:NilClass) On 1 Kwi, 07:50, Colin Law clan...@googlemail.com wrote: On 1 April 2010 15:36, Adam anlauf.a...@gmail.com wrote: HI, I have a pretty weird problems withdates. my objective was to parse some text files and put them into a database. the lines of the file are divided with a | and some of the fields are datesin this format dd.mm. now in the parsing a get the system date to skip parsing elements in the past @date is the local date created with @date = Time.now.to_date params[:to] is the string from the file with the date in above format I did this with a simple if params ( params[:to].to_date@date ) # nie parsujemy starych cennikow Price.create_or_update params end on my local enviroment everything works fine but on the remote host i get an invalid date ArgumentError Catch the error in your code and log or display the params[:to] that is causing it. Then you will likely see the problem. It is risky to convert strings to date without checking validity and taking appropriate action anyway. Colin ruby version on host ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-linux] local ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux] any ideas? thanks in advance -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. Hi, Assuming params[:to] is a string like 31.12.2007 you should try : Date.parse(params[:to]) -- Aurélien AMILIN -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: unknown attribute: version (nested forms)
Hi Oren, Try this accepts_nested_attributes_for :versions in the location.rb file. Cheers! On Apr 7, 1:30 am, oren orengo...@gmail.com wrote: ActiveRecord::UnknownAttributeError in LocationsController#update unknown attribute: version RAILS_ROOT: /home/oren/misc/projects/borderstylo/content /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2746:in `attributes=' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2742:in `each' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2742:in `attributes=' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2628:in `update_attributes' /home/oren/misc/projects/borderstylo/content/app/controllers/ locations_controller.rb:29:in `update' On Apr 7, 3:31 am, Ryan Waldron r...@erebor.com wrote: Where's the error message? On Tue, Apr 6, 2010 at 8:49 PM, oren orengo...@gmail.com wrote: I try to update a nested model (version) and get this error. any tips would be great! my models: location has_many :versions # view % form_for location do |location_form| % ul class=location li%= location_form.label location.section %/li li%= location_form.label location.sub_section %/li li%= location_form.label location.place_holder %/li /ul div class=content-area % location.versions.each do |version| % div class=content % location_form.fields_for version do |version_form| % %= version_form.label version.environment % %= version_form.text_area :content % % end % /div % end % %= submit_tag % /div % end % #controller def update �...@location = Location.find(params[:id]) �...@location.update_attributes(params[:location]) #error: unknown attribute: version redirect_to( locations_path ) end # the params {location={version={content=hello human. glass robot want you to join Glass}}, commit=Save changes, authenticity_token=l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=, id=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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: how does Rails / Apache handle database connections?
This helped - thank you! On Apr 6, 1:52 pm, Frederick Cheung frederick.che...@gmail.com wrote: On Apr 6, 5:19 pm, Daniel Higginbotham dan...@flyingmachinestudios.com wrote: Hi all, I'm trying to figure out how Rails handles database connections. The business problem is: * My users have access to multiple, structurally identical schemas * So, for each request, Rails needs to be able to talk to a different schema * It's essential that users not pull data from the wrong schema A couple more rules: * During the request, the schema used will not change * All the schemas can be accessed from one database server using one set of login credentials The solution I'm contemplating is to execute a use statement for each request, so that all subsequent queries use the correct table. My questions are: * How many database connections does each Rails process create? * Does this vary by adapter? (I'm using MS SQL Server) * Does apache pool database connections in any way? * Are database connections independent of Rails processes on apache? Each rails process has a pool of connections (by default up to 5). I believe you can add a hook that runs after a connection is checked out (eg to set the current database). This layer of abstraction is independent of the various adapters. If you are using a multithreaded environment (of which the only one of note are the jruby ones, which your questions about apache imply you are not using) then you might have to be extra specially careful Apache doesn't come into this at all. 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] has_many :through and named_scope
Hi I have the models roles, users and user_roles. The relationship among them is user.r --- user has_many user_roles user has_many roles, :through = :user_roles role.rb === role has_many user_roles role has_many users, :through = :user_roles user_role.rb belongs_to :user belongs_to :role Suppose a login user1 has roles [admin, staff] And login user2 has only one role say [participant] Now how can I check the cases 1)a login user is an admin or staff 2) a login user has_role participant? And also I would like to know whether this can be written using named scopes.(I am totally new to named scopes) Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: weird dates problem
I've tried that too but stille get an argument error with invalid date, i've log the dates an they look fine (the format's ok) ;/ Really hate this kind of errors On 7 Kwi, 03:47, AMILIN Aurélien aurelien.ami...@gmail.com wrote: Le 07/04/2010 12:41, Adam a crit : sory for the long absence (holidays) well the params[:to] is a date in this format 27.02.2010, but when i try to log params[:to].to_date I get an error NoMethodError( undefined method'[]' for nil:NilClass) On 1 Kwi, 07:50, Colin Law clan...@googlemail.com wrote: On 1 April 2010 15:36, Adam anlauf.a...@gmail.com wrote: HI, I have a pretty weird problems withdates. my objective was to parse some text files and put them into a database. the lines of the file are divided with a | and some of the fields are datesin this format dd.mm. now in the parsing a get the system date to skip parsing elements in the past @date is the local date created with �...@date = Time.now.to_date params[:to] is the string from the file with the date in above format I did this with a simple if params ( params[:to].to_date @date ) # nie parsujemy starych cennikow Price.create_or_update params end on my local enviroment everything works fine but on the remote host i get an invalid date ArgumentError Catch the error in your code and log or display the params[:to] that is causing it. Then you will likely see the problem. It is risky to convert strings to date without checking validity and taking appropriate action anyway. Colin ruby version on host ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-linux] local ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux] any ideas? thanks in advance -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. Hi, Assuming params[:to] is a string like 31.12.2007 you should try : Date.parse(params[:to]) -- Aur lien AMILIN -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: weird dates problem
I'll jutr try (for now) to make the dates by spliting the string and extracting every part of it and making a new Date obj. from those parts On 7 Kwi, 04:53, Adam anlauf.a...@gmail.com wrote: I've tried that too but stille get an argument error with invalid date, i've log the dates an they look fine (the format's ok) ;/ Really hate this kind of errors On 7 Kwi, 03:47, AMILIN Aurélien aurelien.ami...@gmail.com wrote: Le 07/04/2010 12:41, Adam a crit : sory for the long absence (holidays) well the params[:to] is a date in this format 27.02.2010, but when i try to log params[:to].to_date I get an error NoMethodError( undefined method'[]' for nil:NilClass) On 1 Kwi, 07:50, Colin Law clan...@googlemail.com wrote: On 1 April 2010 15:36, Adam anlauf.a...@gmail.com wrote: HI, I have a pretty weird problems withdates. my objective was to parse some text files and put them into a database. the lines of the file are divided with a | and some of the fields are datesin this format dd.mm. now in the parsing a get the system date to skip parsing elements in the past @date is the local date created with �...@date = Time.now.to_date params[:to] is the string from the file with the date in above format I did this with a simple if params ( params[:to].to_date @date ) # nie parsujemy starych cennikow Price.create_or_update params end on my local enviroment everything works fine but on the remote host i get an invalid date ArgumentError Catch the error in your code and log or display the params[:to] that is causing it. Then you will likely see the problem. It is risky to convert strings to date without checking validity and taking appropriate action anyway. Colin ruby version on host ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-linux] local ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux] any ideas? thanks in advance -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. Hi, Assuming params[:to] is a string like 31.12.2007 you should try : Date.parse(params[:to]) -- Aur lien AMILIN -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] JOBS : Ruby on Rails Developer Needed
Hello, Our green recycling company in Wilmington, North Carolina needs of a Ruby on Rails Developer to help track it fast growing client base. This project will be contract based and will require almost one month of full time programming and then weekly/monthly maintenance. Need someone with prior RoR experience and able to show past successful projects completed. Contact: ccalh...@ecocollectionsystems.com -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: named_scope when using foreign keys
There is no managers table, just a relation. Thats the thing: belongs_to :manager, :class_name = User, :foreign_key = manager_id :-) j On 3 Apr, 15:01, Colin Law clan...@googlemail.com wrote: On 3 April 2010 11:42, jeb jo...@ibiz.se wrote: Hi, The error message is: SQLite3::SQLException: no such column: manager.name: SELECT stores.id AS t0_r0, stores.customer_id AS t0_r1, AND ON AND ON There sure is a name column in the users model. This works fine but does not give the same result of course: named_scope :manager_name, lambda{|name| {:include = :users, :conditions = ['users.name = ?', name ]}} :-) j On 2 Apr, 10:56, Colin Law clan...@googlemail.com wrote: On 2 April 2010 09:06, jeb jo...@ibiz.se wrote: Hi all, I can't get this named scope to work. Each store has a number of users. Each store can have one manager. I ant to use a nemed scope to find the manager by name. Have I got this totally backwards? Help appreciated :-) jonas class Store ActiveRecord::Base has_many :users, :dependent = :destroy belongs_to :manager, :class_name = User, :foreign_key = manager_id named_scope :manager_name, lambda{|name| {:include = :manager, :conditions = ['manager.name = ?', name ]}} Has it included the managers table? You have not shown enough of the sql to see. Try it with :include = :managers (plural) Colin That looks ok to me, assuming that thestorestable has a manager_id column. Remember that the named scope will return an array ofstores containing all thestoreswith a manager of that name. If you have already a store in @store then to get the managers name you just need @store.manager.name of course. If that doesn't help post the error you are getting and the code around the error. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Rails Google Visualizations MySql
Im trying to get a gauge to update realtime using javascript in rails, I have got a starting point and the gauges move in realtime using a maths random function. When I try to pull the data from the database It seems that the mysql command is only being called once, it is updated once then it doesnt move again. My code is below, any help would be great. I will first post the variables first that are in the helper. [code] Variables# def timevariables() Log.uncached do @oneminute = 1.minutes.ago @todaydate = 0.days.ago @yesturdaydate = 1.days.ago @lastweekdate = 1.week.ago @lastmonthdate = 1.month.ago @lastyeardate = 1.year.ago @countlogsminute = Log.count(:conditions ={ :datetime = @oneminut...@todaydate}) @countlogs24 = Log.count(:conditions ={ :datetime = @yesturdaydat...@todaydate}) @countlogsweek = Log.count(:conditions ={ :datetime = @lastweekdat...@todaydate}) @countlogsmonth = Log.count(:conditions ={ :datetime = @lastmonthdat...@todaydate}) @countlogsyear = Log.count(:conditions ={ :datetime = @lastyeardat...@todaydate}) end end # ##Gauge Page### %timevariables% div id =subtitleNumber of Events/div script type=text/javascriptCODESITE_docEarlyProcessing();/script script type=text/javascript src=http://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.0','packages':['gauge']}]}/script !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN~CCC http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head /head body onload=load() onunload=GUnload() div id=chart_div style=width: 400px; height: 120px;/div script type=text/javascript function Timer(){this.t={};this.tick=function(a,b){this.t[a]=[(new Date).getTime(),b]};this.tick(start)}var loadTimer=new Timer;window.jstiming={Timer:Timer,load:loadTimer};if(window.externalwindow.external.pageT)window.jstiming.pt=window.external.pageT;if(window.jstiming)window.jstiming.report=function(g,d){var c=;if(window.jstiming.pt){c+=srt=+window.jstiming.pt;delete window.jstiming.pt}if(window.externalwindow.external.tran)c+=tran=+window.external.tran;var a=g.t,h=a.start;delete a.start;var i=[],e=[];for(var b in a){if(b.indexOf(_)==0)continue;var f=a[1];if(f)a[f][0]e.push(b+.+(a[0]-a[f][0]));else hi.push(b+.+(a[0]-h[0]))}if(d)for(var j in d)c+=+j+=+d[j];(new Image).src=[http://csi.gstatic.com/csi?v=3,s=gvizaction=,g.name,e.length?it=+e.join(,)+c:c,rt=,i.join(,)].join()}; /script script type=text/javascript var csi_timer = new window.jstiming.Timer(); csi_timer.name = 'docs_gauge'; google.setOnLoadCallback(drawChart); function drawChart() { csi_timer.tick('load'); var data = new google.visualization.DataTable(); data.addColumn('string', 'Label'); data.addColumn('number', 'Value'); data.addRows(3); data.setValue(0, 0, 'Memory'); data.setValue(0, 1, %...@countlogs24-%); data.setValue(1, 0, 'CPU'); data.setValue(1, 1, 55); data.setValue(2, 0, 'Network'); data.setValue(2, 1, 68); csi_timer.tick('data'); var chart = new google.visualization.Gauge(document.getElementById('chart_div')); csi_timer.tick('new'); var options = {width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom:75, yellowTo: 90, minorTicks: 5, min:0, max:100}; chart.draw(data, options); csi_timer.tick('draw'); window.jstiming.report(csi_timer); setInterval(function() { data.setValue(0, 1,%...@countlogs24-%); chart.draw(data, options); },5000); setInterval(function() { data.setValue(1, 1, 40 + Math.round(60 * Math.random())); chart.draw(data, options); }, 5000); setInterval(function() { data.setValue(2, 1, 60 + Math.round(20 * Math.random())); chart.draw(data, options); }, 26000); } /script div id=map/div /body /html [/code] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Recommendation for searching with regards to timestamp foreign key attributes
hi guys, I need a recommendation for searching with regards to timestamp foreign key attributes. Sounds a bit too much but here's an example. Suppose we have a blog object. It has many attributes such as - title - content - status_id - created_at - updated_at There are also status objects which have the following statuses, new, edit,published,archived. That's why the blog object has a foreign key, status_id. Now, suppose I want to search for all blog objects that have been created in the past 24 hours. I would do new_blogs = Blog.all(:conditions = { :created_at = (Time.now - 24.hours) .. (Time.now) } ) Tested and that works just fine. Suppose I would like to get all blog entries which are not of the status of 'published' or 'archived'. I would just make use of searchlogic in the following way: new_blog_entries = Blog.searchlogic(:status_name_does_not_equal_all = (['published', 'archived']) ) OR new_blog_entries = Blog.status_name_does_not_equal_any(['published', 'archived']) Question: Suppose I now want to get blog entries which 1) have been created within the last 24 hours 2) have a status other than published and archived. Any recommendations for doing this? I couldn't quite work out how to specify the status (as it's a foreign key) to the Blog model in the :conditions AND similarly, I could not quite work out how to specify the created within the last 24 hours filter using searchlogic. I tried new_blog_entries = Blog.status_name_does_not_equal_any(['published', 'archived'])_and_created_at((Time.now - 24.hours) .. (Time.now)) but I got an ugly error of SyntaxError: (irb):42: syntax error, unexpected tIDENTIFIER, expecting $end ...'published', 'archived'])_and_created_at((Time.now - 24.hours) .. (Ti... ... ^ from /usr/local/bin/irb:12:in `main' Any ideas? thanks -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.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] Recommendation for searching with regards to timestamp foreign key attributes
Sorry guys, please replace new_blog_entries = Blog.status_name_does_not_equal_any(['published', 'archived']) with new_blog_entries = Blog.status_name_does_not_equal_all(['published', 'archived']) -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: has_many :through and named_scope
user1.roles returns an array of roles. The array class has a function include?(obj) that returns true or false. Something like this should work: user1.roles.include?(Role.find_by_name('admin')) Named scopes are not ment for stuff like this. You can create a function on the user model is_admin? for the code above. That way if how an admin is defined changes, you only need to update the code in one place. On Apr 7, 1:38 pm, Tom Mac li...@ruby-forum.com wrote: Hi I have the models roles, users and user_roles. The relationship among them is user.r --- user has_many user_roles user has_many roles, :through = :user_roles role.rb === role has_many user_roles role has_many users, :through = :user_roles user_role.rb belongs_to :user belongs_to :role Suppose a login user1 has roles [admin, staff] And login user2 has only one role say [participant] Now how can I check the cases 1)a login user is an admin or staff 2) a login user has_role participant? And also I would like to know whether this can be written using named scopes.(I am totally new to named scopes) Thanks in advance Tom -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Recommendation for searching with regards to timestamp foreign key attributes
If you are using Rails 2.1 or greater, then named_scope would be very useful. In your Blog model for example, you can specify a recent named_scope to return all entries less than 24 hours old. named_scope :recent, :conditions = [ created_at ?, Time.now - 24.hours ] and maybe another one for unpublished entries # modify the conditions and include accordingly as I don't know enough about # your models named_scope :unpublished, :include = :status, :conditions = statuses.status != 'published' In your controllers then, you can do something like @new_unpublished_entries = Blog.unpublished.recent -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: has_many :through and named_scope
Better off saying !roles.find_by_name(admin).blank? Saves on SQL Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r Learn: http://sensei.zenunit.com/ New video up now at http://sensei.zenunit.com/ real fastcgi rails deploy process! Check it out now! On 07/04/2010, at 11:40 PM, Sharagoz shara...@gmail.com wrote: user1.roles returns an array of roles. The array class has a function include?(obj) that returns true or false. Something like this should work: user1.roles.include?(Role.find_by_name('admin')) Named scopes are not ment for stuff like this. You can create a function on the user model is_admin? for the code above. That way if how an admin is defined changes, you only need to update the code in one place. On Apr 7, 1:38 pm, Tom Mac li...@ruby-forum.com wrote: Hi I have the models roles, users and user_roles. The relationship among them is user.r --- user has_many user_roles user has_many roles, :through = :user_roles role.rb === role has_many user_roles role has_many users, :through = :user_roles user_role.rb belongs_to :user belongs_to :role Suppose a login user1 has roles [admin, staff] And login user2 has only one role say [participant] Now how can I check the cases 1)a login user is an admin or staff 2) a login user has_role participant? And also I would like to know whether this can be written using named scopes.(I am totally new to named scopes) Thanks in advance Tom -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Recommendation for searching with regards to timestamp foreign key attributes
bravo! I like the idea, Franz! Thank you :) On 7 April 2010 23:44, Franz Strebel franz.stre...@gmail.com wrote: If you are using Rails 2.1 or greater, then named_scope would be very useful. In your Blog model for example, you can specify a recent named_scope to return all entries less than 24 hours old. named_scope :recent, :conditions = [ created_at ?, Time.now - 24.hours ] and maybe another one for unpublished entries # modify the conditions and include accordingly as I don't know enough about # your models named_scope :unpublished, :include = :status, :conditions = statuses.status != 'published' In your controllers then, you can do something like @new_unpublished_entries = Blog.unpublished.recent -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.comrubyonrails-talk%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: weird dates problem
With strptime you can specify the format: Date.strptime(07.04.2010, %d.%m.%Y) On Apr 7, 2:13 pm, Adam anlauf.a...@gmail.com wrote: I'll jutr try (for now) to make the dates by spliting the string and extracting every part of it and making a new Date obj. from those parts On 7 Kwi, 04:53, Adam anlauf.a...@gmail.com wrote: I've tried that too but stille get an argument error with invalid date, i've log the dates an they look fine (the format's ok) ;/ Really hate this kind of errors On 7 Kwi, 03:47, AMILIN Aurélien aurelien.ami...@gmail.com wrote: Le 07/04/2010 12:41, Adam a crit : sory for the long absence (holidays) well the params[:to] is a date in this format 27.02.2010, but when i try to log params[:to].to_date I get an error NoMethodError( undefined method'[]' for nil:NilClass) On 1 Kwi, 07:50, Colin Law clan...@googlemail.com wrote: On 1 April 2010 15:36, Adam anlauf.a...@gmail.com wrote: HI, I have a pretty weird problems withdates. my objective was to parse some text files and put them into a database. the lines of the file are divided with a | and some of the fields are datesin this format dd.mm. now in the parsing a get the system date to skip parsing elements in the past @date is the local date created with �...@date = Time.now.to_date params[:to] is the string from the file with the date in above format I did this with a simple if params ( params[:to].to_date @date ) # nie parsujemy starych cennikow Price.create_or_update params end on my local enviroment everything works fine but on the remote host i get an invalid date ArgumentError Catch the error in your code and log or display the params[:to] that is causing it. Then you will likely see the problem. It is risky to convert strings to date without checking validity and taking appropriate action anyway. Colin ruby version on host ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-linux] local ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux] any ideas? thanks in advance -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. Hi, Assuming params[:to] is a string like 31.12.2007 you should try : Date.parse(params[:to]) -- Aur lien AMILIN -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Monitoring the changes in div tag
Loganathan Ganesan wrote: You misunderstood the concept. Ya the div is updated by using :update in the link_to_remote. I want something like observe_field to monitor the changes happening in the div tag. Because we can also use :complete to get to know the changes happened in the div But it is for only the particular session. Whereas in the observe_field, it calls the appropriate action whenever changes happened in the select tag. The ajax request will go for all the sessions. Incase of more than one session currently using my application, the link clicked in the particular session only will get to use of the :complete. If any clarifications need revert back me. I think you are misunderstanding how observe_fields works. It does not monitor changes in the DOM, rather it attaches event listeners to each individual form field. Take a look at the list of events that are applicable to HTML elements. Notice there is no onchange event: http://www.w3schools.com/jsref/dom_obj_all.asp The onchange event is applicable to controls (text boxes, popup lists, checkboxes, etc.). The DOM itself doesn't change, rather it gets changed as a result of some other event. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ReadOnly error keeps haunting the objects I want to update on a script (using script/runner)
Got the following from http://ar.rubyonrails.org (Active Record — Object-relation mapping put on rails) --- Start Direct manipulation (instead of service invocation) So instead of (Hibernate example): long pkId = 1234; DomesticCat pk = (DomesticCat) sess.load( Cat.class, new Long(pkId) ); // something interesting involving a cat... sess.save(cat); sess.flush(); // force the SQL INSERT Active Record lets you: pkId = 1234 cat = Cat.find(pkId) # something even more interesting involving the same cat... cat.save --- End I still do not know why my code fails to work when I use script/ runner -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: please help; form_for passes nil
Fred, Is this what you meant? With Firebug open, I go to the form as a user would, change the annotation hypothetical protein to hypothetical proteinski, then click the update button. In firebug, I see a new POST request. I can examine it with any of four Firebug tabs (Headers, Post, Response, HTML). Using the post tab, I see: _method put commit Update orf[current_annotation] hypothetical proteinski Under the Request tab in Firebug, I can examine the Request header, which is: Hostandromeda.micro.umass.edu:8080 User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv: 1.9.1.9) Gecko/20100315 Firefox/3.5.9 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive Referer http://andromeda.micro.umass.edu:8080/orves/1705/edit Cookie []; []; __utma=198765611.347868135.1233253686.1269352816.1269440269.55; __utmz=198765611.1269352816.54.21.utmccn=(organic)|utmcsr=google| utmctr=umass+map|utmcmd=organic; [_baby_session=BAh7BzoPc2Vzc2lvbl9pZCIlMTYxODY1MmVkZDMyOWU3MmJiNjAyM2ZiOTY5NmRmNTNJIgpmbGFzaAY6DWVuY29kaW5nIg1VUy1BU0NJSUlDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA-- ee8a24f1c308ec43a2b838d45cdb58e9a777ed4c; [] On Apr 6, 5:56 pm, Frederick Cheung frederick.che...@gmail.com wrote: On Apr 6, 8:30 pm, dirtbug nyoun...@gmail.com wrote: Colin, The log now shows: Processing OrvesController#update (for 128.119.60.171 at 2010-04-06 14:48:28) [PUT] Have you had a look (with tcpdump, Firebug etc. ) at exactly what your form sends to the server? 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] ReadOnly error keeps haunting the objects I want to update on a script (using script/runner)
Your script seems to be in the body of the Blog model. For what you're trying to do, I suggest that you create a class method in Blog to publish entries e.g. def self.publish_entries # your code goes here end which you can then invoke with Blog.publish_entries Also, the way you are trying to do it is database intensive. The initial search to get new entries is a hit on the db. Then each call to save will hit the db again. I recommend looking up update_all in the Rails API -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Will rake db:migrate:down VERSION=XXX completely remove that migration from Rails?
On Tue, Apr 6, 2010 at 11:29 PM, Ryan Waldron r...@erebor.com wrote: You'll also need to remove that migration's entry from the 'schema_migrations' table. That's how Rails keeps up with what migrations exist, and whether it's done them all. Running rake db:migrate:down VERSION=XXX should remove the entry. Otherwise rake db:migrate wouldn't run the migration again. A normal use case for migrate down is: rake db:migrate #oops something was wrong in migration 123456 rake db:migrate:down VERSION=123456 edit db/migrate/123456_whatever_it_does rake db:migrate On Tue, Apr 6, 2010 at 10:10 PM, GoodGets goodg...@gmail.com wrote: What exactly does rake db:migrate:down VERSION=XXX do? I understand that it runs the down migration, completely removing any columns/ tables that migration may have created, Well it does whatever YOU told it to in the down part of the migration. It's up to you (or whatever you use to edit/generate the migration) to write the correct code there. I tend to use Textmate snippets from the rails bundle to do migrations, and the table/column migration snippets will generate 'undo' code in the down migration when you expand them in the up migration. But YMMV depending on what tools you use. but does this mean that I can can delete these migration files as well? I'd like for Rails to have no knowledge of their existence. (I was allowing user profile pics with Paperclip, but have since decided to just use their Gravatars.) I know you can delete a migration, and even delete those columns from the schema, but Rails still remembers these changes and just updates them the next time you rake db:migrate. So, I'd like to completely rid my app of a particular migration, is rake db:migrate:down then deleting that migration from the migrate folder the way to do it? When you do rake db:migration the rake task looks for migrations under db/migrate which don't have entries in the schema_migrations table, and runs those (actually I think it's a bit more subtle than that, there's been discussion of a 'bug' which can make the task ignore migrations with a timestamp older than the newest one in schema_migrations, which can keep migrations merged from another branch NOT to be run. But... If you run rake db:migrate:down version=XXX and then remove the file db/migrate/XXX_whatever from your source, the rake task won't see it and it will be gone. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] ReadOnly error keeps haunting the objects I want to update on a script (using script/runner)
H makes good sense. I will try it out and report. Thank you, Franz :) On 8 April 2010 00:35, Franz Strebel franz.stre...@gmail.com wrote: Your script seems to be in the body of the Blog model. For what you're trying to do, I suggest that you create a class method in Blog to publish entries e.g. def self.publish_entries # your code goes here end which you can then invoke with Blog.publish_entries Also, the way you are trying to do it is database intensive. The initial search to get new entries is a hit on the db. Then each call to save will hit the db again. I recommend looking up update_all in the Rails API -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.comrubyonrails-talk%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] no newline at end of partial view?
I have a view partial that is used to render a small block of HTML content. Because of where it's going to be placed in the HTML, it's important that it not begin or end with any HTML whitespace. But making a sample view partial that contains nothing but a simple string, just to test things out -- when rendered it seems to still end with a newline, which is of course HTML whitespace. Even though there's no newline in the html.erb file. Is there any simple way to make a partial view render with no newline at the end -- or the more general question, what I'm really after, with no HTML whitespace at the start or end of the partial view content? Thanks for any advice. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] cumulative sum using mysql/rails
I'm having an issue generating a cumulative sum by month in rails. This is what I have: @results = Student.connection.select_all(SELECT x1.MonthNo , x1.MonthName , x1.Added , SUM(x2.Added) AS RunningTotal FROM ( SELECT MONTH(passed_on) AS MonthNo , MONTHNAME(passed_on) AS MonthName , COUNT(*) AS Added FROM students WHERE passed_on = '2009-09-23' GROUP BY MONTH(passed_on) ) AS x1 INNER JOIN ( SELECT MONTH(passed_on) AS MonthNo , MONTHNAME(passed_on) AS MonthName , COUNT(*) AS Added FROM students WHERE passed_on = '2009-09-23' GROUP BY MONTH(passed_on) ) AS x2 ON x1.MonthNo = x2.MonthNo GROUP BY x1.MonthNo;) @result = @results.map{ |result| result[:RunningTotal] } @result returns this: [nil, nil] even though @results returns this: [{RunningTotal=1, MonthName=February, Added=1, MonthNo=2}, {RunningTotal=11, MonthName=March, Added=10, MonthNo=3}] I would like @result to return this: [1,11] Any suggestions 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ReadOnly error keeps haunting the objects I want to update on a script (using script/runner)
On Apr 7, 3:11 pm, ct9a anexi...@gmail.com wrote: I have written a script (which I will paste below). I seem to always get the error below which relates to ActiveRecord::ReadOnlyRecord when I try to save/update the object. projects/myApp/vendor/rails/activerecord/lib/active_record/base.rb: 2867:in `create_or_update': ActiveRecord::ReadOnlyRecord (ActiveRecord::ReadOnlyRecord). That happens if you do a find with a :joins option (unless you override it by passing :readonly = false) 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Retrieve redirect URLs from an URL
Rutvij Pandya wrote: Tom Pett wrote: Anyone got any advice on this situation? dude, do u require to perform any operation btw each redirect?? Reply Not really. I would just like a list of (chain) redirects to write in a database. I just want to extra all redirect information from an URL at any given time. Nothing has to be computed real time or during the redirects for my application. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: cumulative sum using mysql/rails
On Apr 7, 3:48 pm, John Merlino li...@ruby-forum.com wrote: @result returns this: [nil, nil] even though @results returns this: [{RunningTotal=1, MonthName=February, Added=1, MonthNo=2}, {RunningTotal=11, MonthName=March, Added=10, MonthNo=3}] I would like @result to return this: [1,11] Any suggestions thanks? Symbols and strings are not the same thing Fred -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: please help; form_for passes nil
Colin, I added a create method. It seems to create a new object, but doesn't store any content in the fields. On Apr 6, 3:58 pm, Colin Law clan...@googlemail.com wrote: On 6 April 2010 20:30, dirtbug nyoun...@gmail.com wrote: Colin, The log now shows: Processing OrvesController#update (for 128.119.60.171 at 2010-04-06 14:48:28) [PUT] Parameters: {orf=nil, commit=Update, id=1705} Well, amazing, after fixing multiple problems the fundamental issue remains unaffected! Can anyone else see why the orf parameter is nil? I have always used %= f.text_field :field_name ... whereas I see you have %= f.text_field 'field_name' but I would be surprised if this were the problem. The html looks ok. Does it work when creating a new orf record? Colin [4;36;1mOrf Columns (22.6ms) [0m [0;1mSHOW FIELDS FROM `orves` [0m [4;35;1mOrf Load (0.9ms) [0m [0mSELECT * FROM `orves` WHERE (`orves`.`id` = 1705) [0m [4;36;1mSQL (0.2ms) [0m [0;1mBEGIN [0m [4;35;1mSQL (0.3ms) [0m [0mCOMMIT [0m Redirected to /orves/1705 Completed in 49ms (DB: 25) | 302 Found [http:// andromeda.micro.umass.edu/orves/1705] [4;36;1mSQL (0.4ms) [0m [0;1mSET NAMES 'utf8' [0m [4;35;1mSQL (0.3ms) [0m [0mSET SQL_AUTO_IS_NULL=0 [0m Processing OrvesController#show (for 128.119.60.171 at 2010-04-06 14:48:28) [GET] Parameters: {id=1705} [4;36;1mOrf Columns (18.5ms) [0m [0;1mSHOW FIELDS FROM `orves` [0m [4;35;1mOrf Load (0.9ms) [0m [0mSELECT * FROM `orves` WHERE (`orves`.`id` = 1705) [0m Rendering template within layouts/orves Rendering orves/show Completed in 96ms (View: 58, DB: 20) | 200 OK [http:// andromeda.micro.umass.edu/orves/1705] On Apr 6, 3:02 pm, Colin Law clan...@googlemail.com wrote: On 6 April 2010 19:26, dirtbug nyoun...@gmail.com wrote: Colin, I added a layout file that had gone missing and now it validates. The html; Well, that was a worthwhile exercise, even if it was not the cause of the problem. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=content-type content=text/html;charset=UTF-8 / titleOrves: edit/title link href=/stylesheets/baby.css?1270578037 media=screen rel=stylesheet type=text/css / /head body p style=color: green/p h1Editing orf/h1 form action=/orves/1705 class=edit_orf id=edit_orf_1705 method=postdiv style=margin:0;padding:0input name=_method type=hidden value=put //div Gura_0317 input id=orf_current_annotation name=orf[current_annotation] size=50 type=text value=hypothetical protein / input id=orf_submit name=commit type=submit value=Update / /form /body /html And the validation report: HTML Validator 0 errors, 0 warnings The validated page has no errors, no warning found by the SGML Parser and HTML Tidy. But it still doesn't update the database. The other thing I asked a few mails ago was what is shown in the log when you click submit, now that you have corrected several problems. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: cumulative sum using mysql/rails
Frederick Cheung wrote: On Apr 7, 3:48�pm, John Merlino li...@ruby-forum.com wrote: I would like @result to return this: [1,11] Any suggestions thanks? Symbols and strings are not the same thing Fred -- But even this: @result = @results.map{ |result| result['RunningTotal'] } returns this: [1, 11] Which is not helping me either, because I believe I need something like this: [1,11] for the chart I'm using. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: cumulative sum using mysql/rails
Nevermind I figured it out. I just need to_i -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] count(*) in find :select returns a String? Why not Fixnum?
clicks = Click.find(:all,:select=count(*) as count, date, :group=date) = [#Click date: 2010-04-05, #Click date: 2010-04-06, #Click date: 2010-04-07] clicks[0].count.class = String Should this return a String? I would think it would surely be a Fixnum. Am I crazy? Is this a bug in rails? Anyone know a way to get around this? I need to make it a Fixnum or Float using count(*) in find. Casting it using to_i after the fact will not work in my scenario. I need to this to be correct when it returns the clicks array. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] count(*) in find :select returns a String? Why not Fixnum?
On Wed, Apr 7, 2010 at 8:27 AM, Yanni Mac li...@ruby-forum.com wrote: clicks = Click.find(:all,:select=count(*) as count, date, :group=date) = [#Click date: 2010-04-05, #Click date: 2010-04-06, #Click date: 2010-04-07] clicks[0].count.class = String Should this return a String? I would think it would surely be a Fixnum. Am I crazy? Is this a bug in rails? I believe 'clicks' is not what you think it is. Try using `inspect` to examine clicks, clicks[0], etc. -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: please help; form_for passes nil
When I did create, it did make an object and a row in the database table. When I go in thru mysql, I can see that it was able to fill three fields: id (which is an autoincrement field), the created_at and updated_at fields, which got timestamps, but none of the info that I had entered into the boxes in the form made it into the db. On Apr 6, 3:58 pm, Colin Law clan...@googlemail.com wrote: On 6 April 2010 20:30, dirtbug nyoun...@gmail.com wrote: Colin, The log now shows: Processing OrvesController#update (for 128.119.60.171 at 2010-04-06 14:48:28) [PUT] Parameters: {orf=nil, commit=Update, id=1705} Well, amazing, after fixing multiple problems the fundamental issue remains unaffected! Can anyone else see why the orf parameter is nil? I have always used %= f.text_field :field_name ... whereas I see you have %= f.text_field 'field_name' but I would be surprised if this were the problem. The html looks ok. Does it work when creating a new orf record? Colin [4;36;1mOrf Columns (22.6ms) [0m [0;1mSHOW FIELDS FROM `orves` [0m [4;35;1mOrf Load (0.9ms) [0m [0mSELECT * FROM `orves` WHERE (`orves`.`id` = 1705) [0m [4;36;1mSQL (0.2ms) [0m [0;1mBEGIN [0m [4;35;1mSQL (0.3ms) [0m [0mCOMMIT [0m Redirected to /orves/1705 Completed in 49ms (DB: 25) | 302 Found [http:// andromeda.micro.umass.edu/orves/1705] [4;36;1mSQL (0.4ms) [0m [0;1mSET NAMES 'utf8' [0m [4;35;1mSQL (0.3ms) [0m [0mSET SQL_AUTO_IS_NULL=0 [0m Processing OrvesController#show (for 128.119.60.171 at 2010-04-06 14:48:28) [GET] Parameters: {id=1705} [4;36;1mOrf Columns (18.5ms) [0m [0;1mSHOW FIELDS FROM `orves` [0m [4;35;1mOrf Load (0.9ms) [0m [0mSELECT * FROM `orves` WHERE (`orves`.`id` = 1705) [0m Rendering template within layouts/orves Rendering orves/show Completed in 96ms (View: 58, DB: 20) | 200 OK [http:// andromeda.micro.umass.edu/orves/1705] On Apr 6, 3:02 pm, Colin Law clan...@googlemail.com wrote: On 6 April 2010 19:26, dirtbug nyoun...@gmail.com wrote: Colin, I added a layout file that had gone missing and now it validates. The html; Well, that was a worthwhile exercise, even if it was not the cause of the problem. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=content-type content=text/html;charset=UTF-8 / titleOrves: edit/title link href=/stylesheets/baby.css?1270578037 media=screen rel=stylesheet type=text/css / /head body p style=color: green/p h1Editing orf/h1 form action=/orves/1705 class=edit_orf id=edit_orf_1705 method=postdiv style=margin:0;padding:0input name=_method type=hidden value=put //div Gura_0317 input id=orf_current_annotation name=orf[current_annotation] size=50 type=text value=hypothetical protein / input id=orf_submit name=commit type=submit value=Update / /form /body /html And the validation report: HTML Validator 0 errors, 0 warnings The validated page has no errors, no warning found by the SGML Parser and HTML Tidy. But it still doesn't update the database. The other thing I asked a few mails ago was what is shown in the log when you click submit, now that you have corrected several problems. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] count(*) in find :select returns a String? Why not Fixnum?
On 7 April 2010 16:27, Yanni Mac li...@ruby-forum.com wrote: clicks = Click.find(:all,:select=count(*) as count, date, :group=date) = [#Click date: 2010-04-05, #Click date: 2010-04-06, #Click date: 2010-04-07] clicks[0].count.class = String Should this return a String? I would think it would surely be a Fixnum. Am I crazy? Is this a bug in rails? Anyone know a way to get around this? I need to make it a Fixnum or Float using count(*) in find. Casting it using to_i after the fact will not work in my scenario. I need to this to be correct when it returns the clicks array. Create a method that returns what you want (by manipulating the string however is needed). particularly if you are likely to ever to need this number in two places in the code - abstract it to stay DRY: # your model def click_count Click.find(:all,:select=count(*) as count, date, :group=date).first.count.to_i end # or on the Click model def self.click_count Click.find(:all,:select=count(*) as count, date, :group=date).first.count.to_i end so you can use your_model.click_count, or Click.click_count and be returned an integer. But would you not be better using the AR Model.count method rather than changing the select condition of .find? http://api.rubyonrails.org/classes/ActiveRecord/Calculations/ClassMethods.html#M002187 -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: count(*) in find :select returns a String? Why not Fixnum?
Hassan, thanks for quick the reply. I am not really sure what you mean by this, though. The above example shows that clicks returns an array of clicks. I am just taking the first click object and seeing what data type it is using .class Here is a closer look at the first object in the array. As you can see, Rails converted count(*) as count to a String. clicks[0].attributes = {date=Mon, 05 Apr 2010, count=1} Maybe this is a MySQL issue.. I am testing right now to see what the data type of count(*) is from mysql. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: count(*) in find :select returns a String? Why not Fixnum?
# your model def click_count Click.find(:all,:select=count(*) as count, date, :group=date).first.count.to_i end # or on the Click model def self.click_count Click.find(:all,:select=count(*) as count, date, :group=date).first.count.to_i end so you can use your_model.click_count, or Click.click_count and be returned an integer. Michael, thanks for the reply. Getting the first row click count does not really help since I am grouping by date. This find statement will return many rows. Example: Date | Count jan 1, 5 jan 2, 6 jan 3, 2 I could iterate thru each date and perform the find count, but that is extremely inefficient. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: count(*) in find :select returns a String? Why not Fixnum?
On 7 April 2010 16:58, Yanni Mac li...@ruby-forum.com wrote: Getting the first row click count does not really help since I am grouping by date. This find statement will return many rows. Example: Date | Count jan 1, 5 jan 2, 6 jan 3, 2 I could iterate thru each date and perform the find count, but that is extremely inefficient. Ah! Sorry... missed that. Just a thought... can you be sneaky and add an accessor method to Click? # Click model def count read_attribute(:count).to_i rescue nil end No idea if it'll work... maybe worth a bash... -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: count(*) in find :select returns a String? Why not Fixnum?
I am also not crazy about using Model.count, because it just returns an ordered hash. Some of my code is dependant on using AR classes when manipulating this data set... might just have to deal with it though and code a workaround. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: no newline at end of partial view?
On Apr 7, 9:43 am, Jonathan Rochkind li...@ruby-forum.com wrote: I have a view partial that is used to render a small block of HTML content. Because of where it's going to be placed in the HTML, it's important that it not begin or end with any HTML whitespace. But making a sample view partial that contains nothing but a simple string, just to test things out -- when rendered it seems to still end with a newline, which is of course HTML whitespace. Even though there's no newline in the html.erb file. Is there any simple way to make a partial view render with no newline at the end -- or the more general question, what I'm really after, with no HTML whitespace at the start or end of the partial view content? My (wild) guess is that it's actually your ERB tag that's adding the newline. You can use a minus sign as part of the closing ERB tag to indicate that you don't want the newline: %= render :partial = 'blah' -% Maybe this will help? Jeff purpleworkshops.com -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: count(*) in find :select returns a String? Why not Fixnum?
Michael Pavling wrote: On 7 April 2010 16:58, Yanni Mac li...@ruby-forum.com wrote: extremely inefficient. Ah! Sorry... missed that. Just a thought... can you be sneaky and add an accessor method to Click? # Click model def count read_attribute(:count).to_i rescue nil end No idea if it'll work... maybe worth a bash... Thanks Michael, that got me thinking! This is a hack, but it still works for me because I can call it on one line. I am developing a reporting system where I convert an ActiveRecord object list to a table, so I really wanted to avoid hard coding something in each class. This allows me to create my list on one line and then pass it to my conversion method. Click.find(:all,:select=count(*) as click_count, date, :group=date).each{|c|c.click_count = c.click_count.to_i} I still want to figure out why count(*) does not return a number data type, but this will work for now. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] select an existing item or create a new one
I have a form that manages a few models, using accepts_nested_attributes_for The new event form passes params like so: event={ name=, happenings_attributes={ 0={ location_attributes={ city=, country=, state= }, location_id=26} } } It all works fine, except I'd like to add a choice of selecting an existing location, or entering values for a new one to be created. I might be going brain dead - I imagine this is a common thing to do - like selecting an existing address or creating new one on an e- commerce site, but alas I've never done it and can't seem to find relevant search results. Things I've tried: --- # option 1: remove the location_attributes at the controller level, if an existing location_id is passed If so, this is the snippet of code I'm using in a before_filter on the create action: params[:event][:happenings_attributes].each do |h| unless h[1][location_id].blank? h[1].delete(location_attributes) end end - which goes ignored and the validations for creating a new location are triggered. I got to the h[1] level by playing around in console like so: params = { event={ name=, happenings_attributes={ 0={ start_at = '2010-03-02', location_attributes={ city=, country=, state= }, location_id=26} } } } params['event']['happenings_attributes'].each do |h| ? puts h.class end Array = {0={location_attributes={city=, country=, state=}, start_at=2010-03-02, location_id=26}} params['event']['happenings_attributes'].each do |h| ? puts h[1][location_id] puts h[1][location_attributes] end 26 citycountrystate # option 2: remove the location_attributes at the model level # Happening model before_validation :check_new_or_existing_location def check_new_or_existing_location if !location_id.blank? location_attributes= nil end end Any suggestions appreciated :) -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Re: count(*) in find :select returns a String? Why not Fixnum?
On 7 April 2010 17:16, Yanni Mac li...@ruby-forum.com wrote: Thanks Michael, that got me thinking! Click.find(:all,:select=count(*) as click_count, date, :group=date).each{|c|c.click_count = c.click_count.to_i} You should still look to putting that code in a method somewhere to avoid duplication. YMMV -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Re: count(*) in find :select returns a String? Why not Fixnum?
I still want to figure out why count(*) does not return a number data type, but this will work for now. The answer's quite straight forward - because Rails doesn't work that way. The typecasting for a MySQL attribute to a Ruby class is done in the read_attribute method in the activerecord/lib/active_record/attribute_methods.rb file. In that method you can see they only typecast the value if column_for_attribute returns the column (i.e. if it's defined in the schema for the table). So, your dynamically created column is not in the schema, so it won't be typecast to an integer. Cheers, Andy -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] array containing fields to display on multiple pages
I would like to have an array saving fields to display for an object that is used for it's form on multiple pages. I have declared the array in each of the controller methods that would use it. for example, def new @echantillon = Echantillon.new @new_ech_columns = Array.new @new_ech_columns = [ [Brut,brut], [Disponibilite,availability], [numero d'inventaire de l'oeuvre,inv], [denomination,name], [numero du laboratoire,oeuvre_work_number], [type d'echantillon,echantillont etc and also in def edit @new_ech_columns = Array.new @new_ech_columns = [ [Brut,brut], [Disponibilite,availability], [numero d'inventaire de l'oeuvre,inv], [denomination,name], [numero du laboratoire,oeuvre_work_number], [type d'echantillon,echantillon etc. and in other methods. Where can I put the array so that I only have to define it once and then use it repeatedly on different pages? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: count(*) in find :select returns a String? Why not Fixnum?
On 7 April 2010 17:03, Michael Pavling pavl...@gmail.com wrote: Just a thought... can you be sneaky and add an accessor method to Click? # Click model def count read_attribute(:count).to_i rescue nil end No idea if it'll work... maybe worth a bash... FYI: This does work. Just tried it here and I get integers returned. No need to do the extra iteration of each result. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Prototype/script-atulo-us guidance needed, I think.
Last night, Ed from the B'more on Rails meetup group gave me the key idea: use ActiveRecord::Observer. So I'm working on doing that. If you post any details about how to do that before I figure it out from the documentation, I'd appreciate any such feedback. -- Richard On Apr 6, 3:47 pm, RichardOnRails richarddummymailbox58...@uscomputergurus.com wrote: Hi, I’ve got an app\views\expenses\new.html.erb file displayed athttp://www.pastie.org/906145. Q1: Lines 22-26, repeated here create a drop-down list of “vendor names” in true Ajax fashion: they push all lower-positioned items south to make room for the vendor names being created. I’d rather cover the lower items while the drop-down is visible, and restore the covered item when the drop-down closes. 22: div id=vendor_droplist style=display:none 23: %= select_tag list, 24: options_for_select(@current_vendors), 25: :multiple = true % 26: /div I tried to modify line 25 to: 25: :multiple = true, :z-index = 2 % but that and other forms yielded syntax-error responses. Q2:. I generated the content of @current_vendors with code in line 14: 14: % @current_vendors = Vendor.find(:all).collect { |vendor| vendor.nickname } % I’d like to each current_vendors item to be a button whose: (i) toString method was invoked by options_for_select for presentation purposes; and (ii) onClick method invoke a specified function that: a. copied the nickname in the drop-down to another text-box; and b. invoked the toggle routine on the drop-down structure (the toggling currently works). I poked around in books and online for an example of this kind of thing, but to no avail thus far. Any suggestions on where to look or how to implement this functionality. Thanks in Advance, Richard -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: no newline at end of partial view?
Jeff Cohen wrote: My (wild) guess is that it's actually your ERB tag that's adding the newline. You can use a minus sign as part of the closing ERB tag to indicate that you don't want the newline: %= render :partial = 'blah' -% Aha, good point! I think you're right. In general, for very white-space-dependent ERB partials, I'm finding it tricky to get the white space right. Are there any special tricks people have in general for controlling whitespace while still leaving readable views, other than %- and -%. I know about those. But even with those, I'm finding I have to jam html tags together in order to get the whitespace I want. Hmm, I just thought of one. Instead of an actual literal: div content /div in the html, which leaves no good way to control output whitespace without also making the HTML kind of hard to read, I could use: %- tag(div) do -% %- content -% %- end -% Which lets me exercize complete control of whitespace supression without actually having to eliminate it in my source. Does that make any sense, or is it completely ridiculous? It's still kind of hard to read, but in deeply nested html, still not as hard to read as divlots of stuffdivmore stuffspanmore stuff/spanstuff/div/div all jammed together without whitespace, because I don't want any whitespace in the output. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: Re: Re: I18n retuns empty string?
I figured out that there's a problem with the .yml file. When I remove my yml file everything works just fine but when I add my .yml file with my customized language strings like: de-DE: time: formats: default: %A, %e. %B %Y, %H:%M Uhr It returns an empty string. I just can't find anything wrong with that default: ? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: no newline at end of partial view?
On Wed, Apr 7, 2010 at 12:09 PM, Jeff cohen.j...@gmail.com wrote: My (wild) guess is that it's actually your ERB tag that's adding the newline. You can use a minus sign as part of the closing ERB tag to indicate that you don't want the newline: %= render :partial = 'blah' -% Where is this kind of erb tags behavior documented? I was looking for it the other day and I failed at Google. -- http://twitter.com/damog http://stereonaut.net/ -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: want to get one-by-one error message
That sounds worse for the user, they have to submit each time only to be told hang on, there's something else wrong - I knew about it before but you're too stupid to be told more than one thing at a time. - dear Andy, Thanks for your help... I too know it's stupidity to show one-by-one message but while you work as developer you need to follow requirements given by client that 's strictly professional in big industry... Regards Rutvij -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Will rake db:migrate:down VERSION=XXX completely remove that migration from Rails?
So as long as I rake db:migrate:down and delete the migration file from my local machine, the production database on the server when it does go live (I haven't launched the app yet) will have no knowledge of this migration having ever existed, right? because that's all I really care about, and I believe this is true, at least from from my understanding now Thank you again Ryan On Apr 6, 11:53 pm, Ryan Waldron r...@erebor.com wrote: It is in whatever database your app is using. Rails creates and maintains it for you. So if your production database is 'foo_prod', there would be a 'schema_migrations' table there, as well as in your 'foo_dev' development database. I don't know of a simple way to remove that row without firing up your database itself (MySQL or whatever). On Tue, Apr 6, 2010 at 10:43 PM, GoodGets goodg...@gmail.com wrote: Thanks Ryan and, I hope this isn't too stupid of a question, but where is this 'schema_migrations' table? On Apr 6, 11:29 pm, Ryan Waldron r...@erebor.com wrote: You'll also need to remove that migration's entry from the 'schema_migrations' table. That's how Rails keeps up with what migrations exist, and whether it's done them all. On Tue, Apr 6, 2010 at 10:10 PM, GoodGets goodg...@gmail.com wrote: What exactly does rake db:migrate:down VERSION=XXX do? I understand that it runs the down migration, completely removing any columns/ tables that migration may have created, but does this mean that I can can delete these migration files as well? I'd like for Rails to have no knowledge of their existence. (I was allowing user profile pics with Paperclip, but have since decided to just use their Gravatars.) I know you can delete a migration, and even delete those columns from the schema, but Rails still remembers these changes and just updates them the next time you rake db:migrate. So, I'd like to completely rid my app of a particular migration, is rake db:migrate:down then deleting that migration from the migrate folder the way to do it? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Will rake db:migrate:down VERSION=XXX completely remove that migration from Rails?
Wow. Thank you Rick. Very nice explanation. Yeah, I dropped the columns by raking 'down' and have also deleted that migration, so I think I'm good to go now. Also, I don't use textmate, but yeah, I made sure that the down migration removed all the columns the up created. Thank you again Mr. Rick On Apr 7, 10:36 am, Rick DeNatale rick.denat...@gmail.com wrote: On Tue, Apr 6, 2010 at 11:29 PM, Ryan Waldron r...@erebor.com wrote: You'll also need to remove that migration's entry from the 'schema_migrations' table. That's how Rails keeps up with what migrations exist, and whether it's done them all. Running rake db:migrate:down VERSION=XXX should remove the entry. Otherwise rake db:migrate wouldn't run the migration again. A normal use case for migrate down is: rake db:migrate #oops something was wrong in migration 123456 rake db:migrate:down VERSION=123456 edit db/migrate/123456_whatever_it_does rake db:migrate On Tue, Apr 6, 2010 at 10:10 PM, GoodGets goodg...@gmail.com wrote: What exactly does rake db:migrate:down VERSION=XXX do? I understand that it runs the down migration, completely removing any columns/ tables that migration may have created, Well it does whatever YOU told it to in the down part of the migration. It's up to you (or whatever you use to edit/generate the migration) to write the correct code there. I tend to use Textmate snippets from the rails bundle to do migrations, and the table/column migration snippets will generate 'undo' code in the down migration when you expand them in the up migration. But YMMV depending on what tools you use. but does this mean that I can can delete these migration files as well? I'd like for Rails to have no knowledge of their existence. (I was allowing user profile pics with Paperclip, but have since decided to just use their Gravatars.) I know you can delete a migration, and even delete those columns from the schema, but Rails still remembers these changes and just updates them the next time you rake db:migrate. So, I'd like to completely rid my app of a particular migration, is rake db:migrate:down then deleting that migration from the migrate folder the way to do it? When you do rake db:migration the rake task looks for migrations under db/migrate which don't have entries in the schema_migrations table, and runs those (actually I think it's a bit more subtle than that, there's been discussion of a 'bug' which can make the task ignore migrations with a timestamp older than the newest one in schema_migrations, which can keep migrations merged from another branch NOT to be run. But... If you run rake db:migrate:down version=XXX and then remove the file db/migrate/XXX_whatever from your source, the rake task won't see it and it will be gone. -- Rick DeNatale Blog:http://talklikeaduck.denhaven2.com/ Github:http://github.com/rubyredrick Twitter: @RickDeNatale WWR:http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn:http://www.linkedin.com/in/rickdenatale -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: unknown attribute: version (nested forms)
I already have this: has_many :versions, :dependent = :destroy accepts_nested_attributes_for :versions On Apr 7, 11:15 am, Nicolas Iensen nicolas.ien...@gmail.com wrote: Hi Oren, Try this accepts_nested_attributes_for :versions in the location.rb file. Cheers! On Apr 7, 1:30 am, oren orengo...@gmail.com wrote: ActiveRecord::UnknownAttributeError in LocationsController#update unknown attribute: version RAILS_ROOT: /home/oren/misc/projects/borderstylo/content /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2746:in `attributes=' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2742:in `each' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2742:in `attributes=' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2628:in `update_attributes' /home/oren/misc/projects/borderstylo/content/app/controllers/ locations_controller.rb:29:in `update' On Apr 7, 3:31 am, Ryan Waldron r...@erebor.com wrote: Where's the error message? On Tue, Apr 6, 2010 at 8:49 PM, oren orengo...@gmail.com wrote: I try to update a nested model (version) and get this error. any tips would be great! my models: location has_many :versions # view % form_for location do |location_form| % ul class=location li%= location_form.label location.section %/li li%= location_form.label location.sub_section %/li li%= location_form.label location.place_holder %/li /ul div class=content-area % location.versions.each do |version| % div class=content % location_form.fields_for version do |version_form| % %= version_form.label version.environment % %= version_form.text_area :content % % end % /div % end % %= submit_tag % /div % end % #controller def update �...@location = Location.find(params[:id]) �...@location.update_attributes(params[:location]) #error: unknown attribute: version redirect_to( locations_path ) end # the params {location={version={content=hello human. glass robot want you to join Glass}}, commit=Save changes, authenticity_token=l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=, id=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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: unknown attribute: version (nested forms)
I use version and not :vorsion here: (since i believe i need to provide an object) location_form.fields_for version do |version_form| could it be related to the issue? On Apr 7, 6:17 pm, oren orengo...@gmail.com wrote: I already have this: has_many :versions, :dependent = :destroy accepts_nested_attributes_for :versions On Apr 7, 11:15 am, Nicolas Iensen nicolas.ien...@gmail.com wrote: Hi Oren, Try this accepts_nested_attributes_for :versions in the location.rb file. Cheers! On Apr 7, 1:30 am, oren orengo...@gmail.com wrote: ActiveRecord::UnknownAttributeError in LocationsController#update unknown attribute: version RAILS_ROOT: /home/oren/misc/projects/borderstylo/content /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2746:in `attributes=' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2742:in `each' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2742:in `attributes=' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2628:in `update_attributes' /home/oren/misc/projects/borderstylo/content/app/controllers/ locations_controller.rb:29:in `update' On Apr 7, 3:31 am, Ryan Waldron r...@erebor.com wrote: Where's the error message? On Tue, Apr 6, 2010 at 8:49 PM, oren orengo...@gmail.com wrote: I try to update a nested model (version) and get this error. any tips would be great! my models: location has_many :versions # view % form_for location do |location_form| % ul class=location li%= location_form.label location.section %/li li%= location_form.label location.sub_section %/li li%= location_form.label location.place_holder %/li /ul div class=content-area % location.versions.each do |version| % div class=content % location_form.fields_for version do |version_form| % %= version_form.label version.environment % %= version_form.text_area :content % % end % /div % end % %= submit_tag % /div % end % #controller def update �...@location = Location.find(params[:id]) �...@location.update_attributes(params[:location]) #error: unknown attribute: version redirect_to( locations_path ) end # the params {location={version={content=hello human. glass robot want you to join Glass}}, commit=Save changes, authenticity_token=l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=, id=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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Need help with ActiveWarehouse-ETL-0.9.1 PG connection problem
I am trying to load conversion data into a postgresql database using activewarehouse-etl. I can create a flat file output from the conversion data without problem. However, when I try to load into the table using the information contained in config/database.yml I see this error: /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ base.rb:1959:in `method_missing': undefined method `postgresql_connection' for #Class:0x2ad8c8e90428 (NoMethodError) Can anyone hazard a guess as to what this means, what might be causing it and how I might fix it? The only reference to `postgresql_connection' that I can find in AR-2.3.5 is this: # activerecord-2.3.5/lib/active_record/connection_adapters/ postgresql_adapter.rb module ActiveRecord class Base # Establishes a connection to the database that's used by all Active Record objects def self.postgresql_connection(config) # :nodoc: config = config.symbolize_keys host = config[:host] port = config[:port] || 5432 username = config[:username].to_s if config[:username] password = config[:password].to_s if config[:password] . . . -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] OT: Country - (State) - City/Town (XML/JSON)
Does anyone know where I can find Country - (State) - City/Town data in easy to read format (XML/JSON)? I need it for my application and would like a good base of countries/states/towns/cities before I start asking users to add missing information. Regards -ants -- 100% naturally selected. 0% designed. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: want to get one-by-one error message
dear Andy, Thanks for your help... I too know it's stupidity to show one-by-one message but while you work as developer you need to follow requirements given by client that 's strictly professional in big industry... I agree, I've had to do some daft things for a client (that I'm still working with) that have nearly caused me to be laughed out of IRC channels... Hopefully the message also gave you ideas for a solution. Cheers, Andy -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: count(*) in find :select returns a String? Why not Fixnum?
You might want to try an after_find() or after_initialize() filter for ActiveRecord. If I remember right they'll let you coerce the value to an integer before the object gets returned to the calling code. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: select an existing item or create a new one
It sounds like you are looking for something like ActiveRecord's find_or_create_by...() or find_or_initialize_by...() methods. You might look into Dynamic attribute-based finders on http://api.rubyonrails.org/classes/ActiveRecord/Base.html -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] best file uploader?
Hey guys I'm asking for your opinion on the best file uploader plugin/gem for ruby on rails. Acts as attachment? File column plugin? Fleximage? others? What do you guys think? Whats your favorite, which one should i use? Thanks -David -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] best file uploader?
Paperclip is really good stuff. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: select an existing item or create a new one
Thanks for your reply. Yeah I didn't think that was suitable in this case, with several fields, showing the user both options in the form etc. Anyway, I just figured out the issue... I was using resource_controller and was trying to delete the nested attributes (if not required) in a create.before... method. If I change that to using a regular create method it works fine. On Apr 7, 8:54 pm, g_f 8si.g...@gmail.com wrote: It sounds like you are looking for something like ActiveRecord's find_or_create_by...() or find_or_initialize_by...() methods. You might look into Dynamic attribute-based finders onhttp://api.rubyonrails.org/classes/ActiveRecord/Base.html -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: named_scope when using foreign keys
On 7 April 2010 13:21, jeb jo...@ibiz.se wrote: There is no managers table, just a relation. Thats the thing: belongs_to :manager, :class_name = User, :foreign_key = manager_id So has it included the users table then? Post the whole sql. Colin :-) j On 3 Apr, 15:01, Colin Law clan...@googlemail.com wrote: On 3 April 2010 11:42, jeb jo...@ibiz.se wrote: Hi, The error message is: SQLite3::SQLException: no such column: manager.name: SELECT stores.id AS t0_r0, stores.customer_id AS t0_r1, AND ON AND ON There sure is a name column in the users model. This works fine but does not give the same result of course: named_scope :manager_name, lambda{|name| {:include = :users, :conditions = ['users.name = ?', name ]}} :-) j On 2 Apr, 10:56, Colin Law clan...@googlemail.com wrote: On 2 April 2010 09:06, jeb jo...@ibiz.se wrote: Hi all, I can't get this named scope to work. Each store has a number of users. Each store can have one manager. I ant to use a nemed scope to find the manager by name. Have I got this totally backwards? Help appreciated :-) jonas class Store ActiveRecord::Base has_many :users, :dependent = :destroy belongs_to :manager, :class_name = User, :foreign_key = manager_id named_scope :manager_name, lambda{|name| {:include = :manager, :conditions = ['manager.name = ?', name ]}} Has it included the managers table? You have not shown enough of the sql to see. Try it with :include = :managers (plural) Colin That looks ok to me, assuming that thestorestable has a manager_id column. Remember that the named scope will return an array ofstores containing all thestoreswith a manager of that name. If you have already a store in @store then to get the managers name you just need @store.manager.name of course. If that doesn't help post the error you are getting and the code around the error. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: ReadOnly error keeps haunting the objects I want to update on a script (using script/runner)
yep, Frederick , I read your posting PRIOR to putting this question up. I had also read the API manual and discovered that. As you can see, there's no use of :joins in my script. On 8 April 2010 01:00, Frederick Cheung frederick.che...@gmail.com wrote: That happens if you do a find with a :joins option (unless you override it by passing :readonly = false) 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.comrubyonrails-talk%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Problems with no method error with rufus scheduler
Hi, I have a problem with rufus. I created a test.rb file in the /config/ initializers folder. test.rb require 'rubygems' require 'rufus/scheduler' scheduler = Rufus::Scheduler.start_new scheduler.each '10s' do puts hey see you in 10seconds! end works fine so far. Now I change it to: test.rb require 'rubygems' require 'rufus/scheduler' scheduler = Rufus::Scheduler.start_new scheduler.each '10s' do recipe = Recipe.check_for_new_print_jobs end And here I get an error.. etc. method check_for_new_print_jobs not found. The method is in the recipe controller /app/controllers/recipe_controller.rb class RecipeController ApplicationController def index end def show end def check_for_new_print_jobs File.open('test_scheduler', 'a') do |f1| f1 Hey, I am still alive + Time.now.to_s+ \n end end ruby -v ruby 1.8.6 rails -v rails 2.3.5 Can anyone give me a hint? Is there something special to do, because I am calling a method out of a initializer file? Thank you very much. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ActionController::UnknownHttpMethod: ***, accepted HTTP methods are get, head, put, post, delete, and options
Got two of these on one of our sites today within seconds. My guess is that it's a bot scanning for vulnerabilities on the site. Error: ActionController::UnknownHttpMethod: CONNECT, accepted HTTP methods are get, head, put, post, delete, and options Action: Internal URL: http://mail.messaging.microsoft.com:25/ Parameters: {action=, controller=} File: [GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/ request.rb:35 Error: ActionController::UnknownHttpMethod: CONNECT, accepted HTTP methods are get, head, put, post, delete, and options Action: Internal URL: http://www.google.com:443/ Parameters: {action=, controller=} File: [GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/ request.rb:35 I would also like to hear from others experiencing this, and if any precautions should be taken... /nikolaj -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ReadOnly error keeps haunting the objects I want to update on a script (using script/runner)
On Apr 7, 10:11 pm, Gordon Yeong anexi...@gmail.com wrote: yep, Frederick , I read your posting PRIOR to putting this question up. I had also read the API manual and discovered that. As you can see, there's no use of :joins in my script. It's just behind the scenes - there pretty much has to be, since you are fetching instances of Blog but with conditions on the statuses table. You're going to have to delve into searchlogic (I assume that's what you're using) and figure out how to get it to supply readonly = false when it does its find. Fred On 8 April 2010 01:00, Frederick Cheung frederick.che...@gmail.com wrote: That happens if you do a find with a :joins option (unless you override it by passing :readonly = false) 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.comrubyonrails-talk%2Bunsubscrib e...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] best file uploader?
On Wed, Apr 7, 2010 at 4:22 PM, David Zhu dzwestwindso...@gmail.com wrote: Hey guys I'm asking for your opinion on the best file uploader plugin/gem for ruby on rails. Acts as attachment? File column plugin? Fleximage? others? What do you guys think? Whats your favorite, which one should i use? Thanks Paperclip. -- http://twitter.com/damog http://stereonaut.net/ -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] best file uploader?
On Apr 7, 2010, at 1:22 PM, David Zhu wrote: Hey guys I'm asking for your opinion on the best file uploader plugin/gem for ruby on rails. Acts as attachment? File column plugin? Fleximage? others? What do you guys think? Whats your favorite, which one should i use? Thanks As other's have said... Paperclip. But to add a little more signal... Ruby Trends can be useful for things like this. http://rubytrends.com/?style=project -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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] time_select and MultiparameterAssignmentErrors
Hello, I have a couple of time field (MySQL data type: time) start_time and end_time, and I'm trying to use a time_select helper to save the data. Here's how I'm using it: %= form.time_select :activity_start_time, :prompt = true, :ignore_date = true % %= form.time_select :activity_end_time, :prompt = true, :ignore_date = true % and I get this error: 2 error(s) on assignment of multiparameter attributes when it hits the controller at this line: @activity = Activity.new(params[:activity]) Here's the parameters: {authenticity_token=5MmHPVW9VupApm3Qk17OEaf4M5dTk7iw9HhFbhOM3Q0=, activity={name=, notes=, activity_start_time(4i)=10, activity_end_time(4i)=13, activity_start_time(5i)=00, activity_end_time(5i)=00, activity_date=04/03/2010, hours=, description=, activity_type=40}} What am I doing wrong? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Namespaced models with has_many :through
Hi. I'm trying to enable the following has_many :through relationships on some models that, as you can see, these models have been namespaced which appears to be causing my grief: ## app/models/school/course.rb class School::Course ActiveRecord::Base has_many :registrations, :class_name = 'School::Registrations' has_many :students, :through = :registrations end ## app/models/school/registration.rb class School::Registration ActiveRecord::Base belongs_to :course, :class_name = 'School::Course' belongs_to :student, :class_name = 'School::Student' end ## app/models/school/student.rb class School::Student ActiveRecord::Base has_many :registrations, :class_name = 'School::Registration' has_many :courses, :through = :regisrations end The regular has_many and belongs_to relationships work fine. However, if I every try to use one of the has_many :through relationships, I get: ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :regisrations in model School::Student from /home/kendall/namespaced/vendor/rails/activerecord/lib/ active_record/reflection.rb:285:in `check_validity!' from /home/kendall/namespaced/vendor/rails/activerecord/lib/ active_record/associations/has_many_through_association.rb:5:in `initialize' from /home/kendall/namespaced/vendor/rails/activerecord/lib/ active_record/associations.rb:1300:in `new' from /home/kendall/namespaced/vendor/rails/activerecord/lib/ active_record/associations.rb:1300:in `courses' So my question is, does anyone know if/how I can get these relationships to actually work? I know rails' support for namespaced models is sketchy. My use of namespaces isn't a superfluous, aesthetic, or organizational whim. My real application for which this test was contrived needs, if at all possible, to use this feature. I'm using ruby 1.8.6 with rails 2.3.5. Any help would be greatly appreciated! -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: ReadOnly error keeps haunting the objects I want to update on a script (using script/runner)
On that same note, I actually did try to set :readonly = false onto new_blogs = Blog.status_name_does_not_equal_all(['live','archived']) but had no idea of how to do so. I tried something like new_blogs = Blog.status_name_does_not_equal_all(['live','archived'], :readonly=false ) but got a syntax error. Anyway, as per Franz's post, I am going to build a method in the model and see how that goes whilst minimising the hits on the db. thank you On 8 April 2010 07:18, Frederick Cheung frederick.che...@gmail.com wrote: On Apr 7, 10:11 pm, Gordon Yeong anexi...@gmail.com wrote: yep, Frederick , I read your posting PRIOR to putting this question up. I had also read the API manual and discovered that. As you can see, there's no use of :joins in my script. It's just behind the scenes - there pretty much has to be, since you are fetching instances of Blog but with conditions on the statuses table. You're going to have to delve into searchlogic (I assume that's what you're using) and figure out how to get it to supply readonly = false when it does its find. 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: time_select and MultiparameterAssignmentErrors
Update - I just noticed that it will save a new record without this error if I have the minutes other than 00. But there still is an issue, since it saves the parameters as Year and Month instead of Hour and Minute! So this is interpreted as activity_start_time(4i)=10, activity_end_time(4i)=13, activity_start_time(5i)=05, activity_end_time(5i)=05, activity_start_time = 2010-05-01 00:00:00 activity_end_time = 2013-05-01 00:00:00 Has anyone encountered this problem? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: best file uploader?
wow rubytrends is awesome. thanks guys On Apr 7, 5:25 pm, Philip Hallstrom phi...@pjkh.com wrote: On Apr 7, 2010, at 1:22 PM, David Zhu wrote: Hey guys I'm asking for your opinion on the best file uploader plugin/gem for ruby on rails. Acts as attachment? File column plugin? Fleximage? others? What do you guys think? Whats your favorite, which one should i use? Thanks As other's have said... Paperclip. But to add a little more signal... Ruby Trends can be useful for things like this. http://rubytrends.com/?style=project -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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: time_select and MultiparameterAssignmentErrors
Well, I found out that I can't have ANY extra constraints on it. That seems to make time_select parameters interpreted incorrectly. Can't have: :prompt = true :include_blank = true :ignore_date = true So my form field is reduced to: %= form.time_select :activity_start_time % %= form.time_select :activity_end_time % and @activity.activity_start_time = Time.parse(00:00) @activity.activity_end_time = Time.parse(00:00) inside the controller, so that the current time won't be selected by default for new records. Kind of annoying that I can't have prompt or blank at the top. :-\If anyone has figured out a way to make time_select work as expected, I'm all ears! -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: time_select and MultiparameterAssignmentErrors
So I just scaffolded, tested and successfully reproduced your problem exactly. Playing around in the console gave some interesting results: Activity.new 'activity_start_time(1i)' = '2010', 'activity_start_time(22i)' = '11', 'activity_start_time(100i)' = '7' ... activity_start_time: 2010-07-11 00:00:00 So for multiparameter attribute assignment, it just sorts the index number alphabetically and uses the data fields to assign to the object, in order (at least for Time / DateTime objects and likely for Date objects as well). It then appears to begin assigning the data to the fields, starting with the first field (year) and moving on, ignoring the actual numeric value of the index (such as my 100 above which results in its value becoming the month). So, with the rails helper defaults of '4i' and '5i', the 5 becomes the 'month' and '00' is an invalid month number. So, this would appear to be a weakness/bug in rails from my perspective. I'd think it should actually strip off the data-type character (the 'i' chars in this case) and cast the remaining 'index' characters to a Fixnum (again, at least for date/time types, not sure about aggregates/others) at which point it should respect the number as an offset: 1 = year, 2 = month, and so on so that this usage, as written out by the view helper, actually works as expected. Anyhow, just my two cents. To work around, I'd drop the :ignore_date options in your helpers. Then manually overwrite the -MM-DD value(s) of these two fields to a consistent default (since I'm assuming you're not using the date part anyway) so you can compare time values. Then you should file a bug report :-) -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Retrieve redirect URLs from an URL
I have found the gem HTTParty which is supposed to help me with this task. I am having some troubles getting this to work on my environment. Currently I run Rails 2.3.5, HTTParty 0.5.2 on Windows Vista (developer machine). I would really appreciate it if someone could give me an example code snippit on how I should do this. Again, imagine the following: URL A redirect to URL B. B redirects to C. C is a normal website that can be retrieved via GET. By supplying A, I want an array in return containing [A,B,C] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: A Confirmation System?
I'd have to agree with Ar Chron, it sounds like you need the PickAxe book from the PragProg publishers, along with AWDwR - both of which should be required reading for noobs. Personally, I went on a turbo learnig curve and went on after those two books with Metaprogramming Ruby, again from Dave Andy @ PragProg, and haven't looked back. It does depend on your knowledge level though. Don't try and run before you can walk. If you are from a OO background then get stuck in and make sure you checkout Meta...Ruby. If you are new to OO, then take your time with the PickAxe book and AWDwR, once you 'think' you understand those, then maybe move on to Meta...Ruby = you can always step back if you need to. As a reult of Meta...Ruby, I have just refactored 100's of lines of biolerplate crap (due to the point I was at in my learning curve with my initial learning project) to a few Ruby modules containing no more than 50 lines of code each - Ruby is a great language (thanks Matz :)) and it is well worth learning its basics first in order to move on after that..take some time learning to Jog on the spot, after a while you will find yourself sprinting the 100m's in under 8 secs... You seem to have your RoR terms mixed up a bit. Forget about the 'scaffold' as such. That is what the generator creates at your command in order to provide you with a starting point for your application - none of it is written in stone - all of it can be tweaked, changed, re- written. Don't forget, you can generate models, migrations, etc. All that the generator is, is Ruby code that creates files based on the Rails Framework to save you the job of creating those files manually. The generator created scaffold includes, most imprortantly (in my eyes); your controllers, your models and your migrations. Also created are your Views and test beds. Personally, I don't care about the Views, because I use Flex for the front end which connects to RoR via Flash's RemoteObject and RubyAMF. I hold my hand up to say I need to look more into the test files (fixtures, unit, helpers, etc) myself. Haven't found the need for those yet due to creating EXE's that test my DB and server functionality - they may save me some work as per most of the RoR framework - just need to find the ROI for the learning curve... Your 'Submit' action has nothing to do with your scaffold, other than, presumably, your submit button in your generated scaffold View. Your original question sounds like the following: User accesses and fills in the form User submits the form Administrator (of sorts) receives notification the form has been submitted Administrator accepts or dismisses the submitted form If so, then all you need to do, is to set up your DB to accept new submissions. You can then decide how you want your Administrator to be notified : this would depend on Application/Business/Project specific directives - Admin logs in and downloads latest submissions written to the DB, latest submissions get written to a log file that the Admin can access, Admin gets e-mail confirming latest submission etc. Is this correct? Regards Paul On Apr 7, 4:36 am, Ryan Waldron r...@erebor.com wrote: David, I don't know if this would help you, but you might poke around inhttp://github.com/subwindow/needs_approvalfor some ideas. I've not used it, so I don't know how mature it is. On Tue, Apr 6, 2010 at 5:08 PM, David Zhu dzwestwindso...@gmail.com wrote: Hey, I'm not sure how complex this really is, but i hope it isn't too difficult for you guys to explain here My question is, is there a way to intercept a Submit action (for a scaffold, etc) of a form, and take that submit action and present it to an ADMIN user, where he/she can either finish submitting the form, or ignore the request? Kind of a like a confirmation system.. Hopefully you guys can help me out, I'm not that good at ruby on rails, but hopefully ill get better :) Thanks for your help! -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: group objects by month
thanks On Apr 7, 12:28 pm, Ryan Waldron r...@erebor.com wrote: If :birth_date is a Date, for instance, you could do it like this: @dogs.group_by{|dog| dog.birth_date.month} On Tue, Apr 6, 2010 at 9:36 PM, eggie5 egg...@gmail.com wrote: or group by week for that matter... On Apr 7, 11:35 am, eggie5 egg...@gmail.com wrote: I have a collection of of objects from an query. I can group them by using: @dogs.group_by(:birth_date) that works fine... and it groups them by date, however, I want to group them by month. How can I do 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] periodically_call_remote renders Page in page
I am using Periodically_call_remote in the following way div id=refresh %= periodically_call_remote( :update = refresh, :frequency = 3, :url = { :action = :activate }) % /div and the action i am calling is shown below. The activate action checks for some value in a remote database and once the value says Active then i want the user to be redirected to another page. But what is happening is that the new page is getting loaded inside the Div refresh tag. So its a page in page. def activate ---perform something--- if ( Check = active) redirect to different page end end Any idea how i can do rectify this. Any other suggestions are welcome too. Ashwin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] How do I update middleware for Rails 3?
Hello, I'm updating an application to Rails 3 that has Uploadify implemented as described by John Nunemaker here: http://railstips.org/blog/archives/2009/07/21/uploadify-and-rails23/ My questions are: 1) Where should middleware live in a Rails 3 application? app/middleware? 2) Is the middleware path loaded in config/application.rb? Or is there a way to do it in config/environment.rb? 3) What should I update the following code to to make it work in Rails 3? # config/initializers/session_store.rb ActionController::Dispatcher.middleware.insert_before( ActionController::Session::CookieStore, FlashSessionCookieMiddleware, ActionController::Base.session_options[:key] ) Specifically, how do I call each of the following: - ActionController::Dispatcher.middleware.insert_before - ActionController::Session::CookieStore - ActionController::Base.session_options[:key] I've looked through the Rails 3 source, and tried various combinations e.g., ActionDispatch::Cookies, ActionDispatch::Middleware::Cookies, ActionController.cookies, etc., but to no avail. Thanks, Patrick -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] quick and easy has_many routes question.
Hey, i have- map.resources :courses, :has_many = :pages now what if i wanted for courses to has_many = :forums as well? can i just do map.resources :courses, :has_many = :pages, :forums ?? because that doesn't work. whats the syntax for- has many blank AND blank.. lol reall noobie i know, but i just don't know how to do it. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: A Confirmation System?
wow paul thanks so much for that explanation. You are correct on what I'm trying to do. Great. Lightbulb moment. 5 star post right there, thanks a lot :D :D :D :D -David On Apr 7, 7:51 pm, paul h p...@hollyer.me.uk wrote: I'd have to agree with Ar Chron, it sounds like you need the PickAxe book from the PragProg publishers, along with AWDwR - both of which should be required reading for noobs. Personally, I went on a turbo learnig curve and went on after those two books with Metaprogramming Ruby, again from Dave Andy @ PragProg, and haven't looked back. It does depend on your knowledge level though. Don't try and run before you can walk. If you are from a OO background then get stuck in and make sure you checkout Meta...Ruby. If you are new to OO, then take your time with the PickAxe book and AWDwR, once you 'think' you understand those, then maybe move on to Meta...Ruby = you can always step back if you need to. As a reult of Meta...Ruby, I have just refactored 100's of lines of biolerplate crap (due to the point I was at in my learning curve with my initial learning project) to a few Ruby modules containing no more than 50 lines of code each - Ruby is a great language (thanks Matz :)) and it is well worth learning its basics first in order to move on after that..take some time learning to Jog on the spot, after a while you will find yourself sprinting the 100m's in under 8 secs... You seem to have your RoR terms mixed up a bit. Forget about the 'scaffold' as such. That is what the generator creates at your command in order to provide you with a starting point for your application - none of it is written in stone - all of it can be tweaked, changed, re- written. Don't forget, you can generate models, migrations, etc. All that the generator is, is Ruby code that creates files based on the Rails Framework to save you the job of creating those files manually. The generator created scaffold includes, most imprortantly (in my eyes); your controllers, your models and your migrations. Also created are your Views and test beds. Personally, I don't care about the Views, because I use Flex for the front end which connects to RoR via Flash's RemoteObject and RubyAMF. I hold my hand up to say I need to look more into the test files (fixtures, unit, helpers, etc) myself. Haven't found the need for those yet due to creating EXE's that test my DB and server functionality - they may save me some work as per most of the RoR framework - just need to find the ROI for the learning curve... Your 'Submit' action has nothing to do with your scaffold, other than, presumably, your submit button in your generated scaffold View. Your original question sounds like the following: User accesses and fills in the form User submits the form Administrator (of sorts) receives notification the form has been submitted Administrator accepts or dismisses the submitted form If so, then all you need to do, is to set up your DB to accept new submissions. You can then decide how you want your Administrator to be notified : this would depend on Application/Business/Project specific directives - Admin logs in and downloads latest submissions written to the DB, latest submissions get written to a log file that the Admin can access, Admin gets e-mail confirming latest submission etc. Is this correct? Regards Paul On Apr 7, 4:36 am, Ryan Waldron r...@erebor.com wrote: David, I don't know if this would help you, but you might poke around inhttp://github.com/subwindow/needs_approvalforsome ideas. I've not used it, so I don't know how mature it is. On Tue, Apr 6, 2010 at 5:08 PM, David Zhu dzwestwindso...@gmail.com wrote: Hey, I'm not sure how complex this really is, but i hope it isn't too difficult for you guys to explain here My question is, is there a way to intercept a Submit action (for a scaffold, etc) of a form, and take that submit action and present it to an ADMIN user, where he/she can either finish submitting the form, or ignore the request? Kind of a like a confirmation system.. Hopefully you guys can help me out, I'm not that good at ruby on rails, but hopefully ill get better :) Thanks for your help! -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at
[Rails] Re: Best way of sorting/grouping objects
Thanks Angelo! That is a great idea. In the long run that would probably make more sense. But in the meantime I'll look into the :group fix. What exactly does that do? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: time_select and MultiparameterAssignmentErrors
Thanks for confirming what I was experiencing! (At least I know I'm not seeing things...) I've never submitted a bug report for ror - is this the right place? https://rails.lighthouseapp.com/dashboard -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] 500 internal server error sqlite 3
I'm new to rails and I have created a project in rubymine and I started up the server then i went to one of my actions i created and i got 500 internal server error! I have no idea how to get it working please help Here is the log file /!\ FAILSAFE /!\ Wed Apr 07 18:39:32 -0700 2010 Status: 500 Internal Server Error unknown error C:/ruby/lib/ruby/1.8/dl/import.rb:29:in `initialize' C:/ruby/lib/ruby/1.8/dl/import.rb:29:in `dlopen' C:/ruby/lib/ruby/1.8/dl/import.rb:29:in `dlload' C:/ruby/lib/ruby/1.8/dl/import.rb:27:in `each' C:/ruby/lib/ruby/1.8/dl/import.rb:27:in `dlload' C:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/dl/api.rb:31 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/dl/driver.rb:1 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' C:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/database.rb:619:in `load_driver' C:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/database.rb:617:in `each' C:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/database.rb:617:in `load_driver' C:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/database.rb:72:in `initialize' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `new' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `sqlite3_connection' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout' C:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:93:in `call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call'
[Rails] Re: Open Source UML Tool for Ruby on Rails?
lambo4jos wrote: I am new to web development, Ruby on Rails, and UML as well. I was wondering if there were any free tools available for UML design. There is a list of free tools on wikipedia under UML tools, but I don't understand if I need a tool that supports the ruby language. If anyone uses a free UML tool for designing Ruby on Rails apps, please let me know what you use. I think the best idea is a open soure and multi plaftorm CASE tools I guess you work in linux or maybe mac.. so try this: http://case-tools.org/ I recommend you to take a simple tools for single user, are easier to learn and more usable (generally) 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Modelling Question - developing meta system
Thanks Fred On Apr 7, 11:02 am, Frederick Cheung frederick.che...@gmail.com wrote: On Apr 7, 9:32 am, johnmcau...@gmail.com johnmcau...@gmail.com wrote: Hey everyone, Just a quick Q. Can anybody point me to some resources regarding a modeling quandary I am in. I have to develop a meta system that allows users to specify their own model variables. For instance, I have a model Team and the users must be able to define, through a simple web interface, variables such as name (specifying the variable as a string), number of players (specifying the variable as a drop down of numbers) and then other users can enter teams into the system. This is similar to content creation kit in drupal but a lot less DRUPAL and a lot more rails. I can put this together but think that I will end up with a messy application that will ultimately serve to frustrate. Has anybody come across discussion on this before? Well you could model this as Team having many attributes and the attributes table stores key value pairs. You could separately store which attributes are permissible for the Team model. You might also find that a document database like couchdb makes this less hassle. 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ReadOnly error keeps haunting the objects I want to update on a script (using script/runner)
Franz, I started out by defining publish_entries in the model of Blog and got the ugly method_missing error when I ran script/runner script/set_blogs_to_published.rb. Of course , this is how my script/set_blogs_to_published.rb looks like. script/set_blogs_to_published.rb - Start --- class Blog ActiveRecord::Base Blog.publish_entries end script/set_blogs_to_published.rb - End --- I then moved publish_entries to the Blog controller file but still no luck when I ran script/set_blogs_to_published.rb. Where do I put the publish_entries definition (ie controller or model of Blog)? On Apr 8, 12:35 am, Franz Strebel franz.stre...@gmail.com wrote: Yourscriptseems to be in the body of the Blog model. For what you're trying to do, I suggest that you create a class method in Blog to publish entries e.g. def self.publish_entries # your code goes here end which you can then invoke with Blog.publish_entries -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: 500 internal server error sqlite 3
try instantrails on windows. that's easy for new comer. Joey Campbell li...@... writes: I'm new to rails and I have created a project in rubymine and I started up the server then i went to one of my actions i created and i got 500 internal server error! I have no idea how to get it working please help Here is the log file -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ruby script - how to write one that deals with different environment?
hi there, bseanvt, The thought of using the rake task is good but it's not applicable to my situation whereby I am just running this script after each run of thinking_sphinx:index which takes place every 20 mins. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ruby script - how to write one that deals with different environment?
http://www.ameravant.com/posts/recurring-tasks-in-ruby-on-rails-using-runner-and-cron-jobs On Apr 6, 9:49 pm, Gordon Yeong anexi...@gmail.com wrote: guys, in addition to Peter's reply, here's a good reference for script/runner. On 6 April 2010 19:55, Peter Hickman peterhickman...@googlemail.com wrote: If you use script/runner then just use them as you normal would. Scripts run from script/runner run as normal rails application so all the same setup that the web application has will be provided for your script. -- -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.