[Rails] Re: Removing part of a String
Rick Lloyd wrote: Dir.entries(public/images/icons) should do nicely... And in any case: fil = public/images/icons/hello.ico p fil.sub(public/images/icons/, ) --output:-- hello.ico -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Rails SequencedHash source file.
Rick Lloyd wrote: gem install collections require 'collections' That does it!! Thanks. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Removing part of a String
JannaB wrote: I want to get the names of all files in a given directory. When I employ the Dir[] method, it returns the name of the files with the pathname I invoked it with: allfiles = Dir[public/images/icons/**] So to remedy this, I try to sub out the directory prefixing the string, as: for fil in allfiles do render :text = fil.sub( public/images/icons/, ) end Yet even this doesn't remove the directory name. Clearly I am doing something stooopid, but just don't see it. Can someone please have a look and see what I am missing here? Thanks you, Janna require 'pathname' allfiles = Pathname.new('/opt') allfiles.children.map{|a| a.basename.to_s} or Dir.chdir(/opt) do allfiles = Dir[**] end -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: what database field type should i use ??
in database only ...i am going to store both string /id in database only On May 7, 4:45 pm, Colin Law clan...@googlemail.com wrote: In the case of method 2 where would you store the tens of thousands of strings if not in the database? Colin 2009/5/7 Vipin sh.vi...@gmail.com in a database table if there is a field which has a certain set of fixed values. for example staus = {Single, Married, Divorced } OR state = {California, Albama, Olaska ...} so what should be preferred way out of the following for storing the values 1. Keep the field as string(Rails) VARCHAR(MySQL) itself and while showing the field just show the field value. 2. Keep the field internally as a code like {:california = 01, :albama = 02, washington = 03 } but while showing the state show only the corresponding state. By using option 2, a certain disadvantage is extra computation time required to find out corresponding state name based on code when showing the state field to user. But an advantage could be in terms of smaller database. In my opinion, saving 01 as an integer could save significant space than storing california if number of records happen to be in tens of thousands . please suggest ?? vipin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: what database field type should i use ??
On May 7, 5:47 pm, Tom Z Meinlschmidt to...@meinlschmidt.org wrote: just realize... in the case od 1st method: everything is simple, but db grows.. but... you made some typo mistake (eg Albama instead of Alabama) and what then.. repair entire table to get the correct results? weird 2nd method: I'm using it for a small enumeration lists (not hundreds/thousands items - then is better to use db enumeratin methods, like countries table and country_id column) in app/model/some_model.rb @@enum_list = %w( value1 value2 value3 ) # to use in erb templates for form.select() helper def self.enum_list_for_select @@enum_list.enum_with_index.collect{|k,v| [k,v]} end def enum_list_to_text self.enum_list.nil? ? 'undefined' : @@enum_list[self.enum_list] end tom Vipin wrote: in a database table if there is a field which has a certain set of fixed values. for example staus = {Single, Married, Divorced } OR state = {California, Albama, Olaska ...} so what should be preferred way out of the following for storing the values 1. Keep the field as string(Rails) VARCHAR(MySQL) itself and while showing the field just show the field value. 2. Keep the field internally as a code like {:california = 01, :albama = 02, washington = 03 } but while showing the state show only the corresponding state. By using option 2, a certain disadvantage is extra computation time required to find out corresponding state name based on code when showing the state field to user. But an advantage could be in terms of smaller database. In my opinion, saving 01 as an integer could save significant space than storing california if number of records happen to be in tens of thousands . please suggest ?? vipin -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === Thanks ! i will try this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: what database field type should i use ??
On May 7, 6:24 pm, Colin Law clan...@googlemail.com wrote: 2009/5/7 Andrew Porter a...@defsdoor.org Vipin wrote: in a database table if there is a field which has a certain set of fixed values. for example staus = {Single, Married, Divorced } OR state = {California, Albama, Olaska ...} so what should be preferred way out of the following for storing the values I use ENUM() columns in mysql - rails treats them as strings so everything works (apart from schema dumps) Sorry, I misunderstood the question, I assumed you wanted to know how to store the country names in a countries table. I did not realise that in option 1 you meant storing the string in every record that references country, though that is what you said, I did not read it carefully. Now that I understand, I would suggest some variant of option 2, store an id in each record referencing a country and determine the string by an enumeration or table lookup later. Worrying too much about computing time during development is a mugs game, an application always ends up with most of its computing time in an area you do not expect. Worry about optimisation later when (or more likely if) a particular area becomes a problem. Colin Colin, yes i guess 2nd variant will be better. thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: what database field type should i use ??
On May 7, 8:09 pm, Billee D. william.dod...@gmail.com wrote: Sometimes it''s a matter of taste or design constraint, but why not use a small join table and a foreign key? ENUM is also a great choice, as these guys have pointed out, but sometimes there is a bit of overhead -- but you shouldn't worry about that until it becomes an issue. Personally, I find it easier to maintain a simple join table and FK relationships than to mess with ENUM field types. I don't know if this is still applicable, but it seems like there is a bit of data massaging in Rails for the ENUM type (Rails converts it internally to VARCHAR): http://lists.rubyonrails.org/pipermail/rails/2005-January/001536.html I like to let the database do as much work as it can, :-) HTH! Billee D. On May 7, 4:43 am, Vipin sh.vi...@gmail.com wrote: in a database table if there is a field which has a certain set of fixed values. for example staus = {Single, Married, Divorced } OR state = {California, Albama, Olaska ...} so what should be preferred way out of the following for storing the values 1. Keep the field as string(Rails) VARCHAR(MySQL) itself and while showing the field just show the field value. 2. Keep the field internally as a code like {:california = 01, :albama = 02, washington = 03 } but while showing the state show only the corresponding state. By using option 2, a certain disadvantage is extra computation time required to find out corresponding state name based on code when showing the state field to user. But an advantage could be in terms of smaller database. In my opinion, saving 01 as an integer could save significant space than storing california if number of records happen to be in tens of thousands . please suggest ?? vipin But Bilee, if we use another table and do the mapping through foreign key won;t it be even poorer as we will be making 2 SQL queries to access the same record. which we are doing in one SQL query in above two methods. But i ll certainly check the link provided. vipin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
You could provide the third button hidden and initially checked. Show it with javascript when one of the other buttons is checked so that the user then has the option of selecting it again. You could then make it disapear again when selected if you wanted to. Colin 2009/5/8 Andrew Vargo ajva...@gmail.com What if you have the third/null value hidden? You can use javascript for a clear choice link or something, which would check the 3, hidden radio button. It could also be the default for new. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: sanitize_params + whiteList
Hi Tom, I've moved the whitelistHelper tag to application_helper.rb, but it still strips all the tags. :( Thx, Pete Tom Z Meinlschmidt wrote: hi, what about to put WhiteListHelper.tags += %w(a em p strong blockquote h2 ul li) into app/helpers/application_helper.rb ? instead of config/... 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-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] STI and subclassing twice
I'm trying using STI to implement a hiearchy similar to this: script/generate scaffold name:string type:string class Person ActiveRecord::Base; end class Customer Person; end class Employee Person; end class Developer Employee; end I.e., there are two levels of inheritance (Developer Employee Person). When creating a Customer, Rails understands it's a Person, but if I create a Developer, Rails 'tends to forget' it's an Employee. In other words: $ script/console Developer.create :name='Bob' = #Developer id: 1, name: Bob, type: Developer, created_at: 2009-05-08 09:59:58, updated_at: 2009-05-08 09:59:58 exit $ script/console Employee.find :all = [] Person.find :all = [#Developer id: 1, name: Bob, type: Developer, created_at: 2009-05-08 09:59:58, updated_at: 2009-05-08 09:59:58] Worst of all, if I change the order of the 'find' statements, things work: $ script/console Person.find :all = [#Developer id: 1, name: Bob, type: Developer, created_at: 2009-05-08 09:59:58, updated_at: 2009-05-08 09:59:58] Employee.find :all = [#Developer id: 1, name: Bob, type: Developer, created_at: 2009-05-08 09:59:58, updated_at: 2009-05-08 09:59:58] Maybe this has to do with some caching stuff... any ideas? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Change onsubmit event key from return key ctrl-return
Hello all, r there any way to change the return key in form single line input ? For example, I want the form to submit the process using ctrl-return key instead of return key because I want to use return key just to add another single line input, can it be done ? thanx all --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: projects works then breaks intermittently - mysql, linux
ok ive rerun the app and recreated the error. Ive attached the entire log development.log file and pasted it below. If whats meant to be there isnt there then its rails fault and not mine. Ive used the development log plenty of times to find sources of errors. Im pretty sure it has something to do with virtual folders. Attachments: http://www.ruby-forum.com/attachment/3669/development.log -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Manifesto and roadmaps for described_routes and path-to
This might make more sense with a concrete example - see http://github.com/asplake/path-to/blob/master/examples/delicious.rb for metadata-driven API access to Delicious, brief writeup at http://positiveincline.com/?p=254. Mike On May 7, 2:05 pm, Mike Burrows (asplake) m...@asplake.co.uk wrote: Hi all, please read on if you're interested in REST and web APIs. I have posted roadmaps for described_routes and path-to (both available as rubygems or at asplake's github) athttp://positiveincline.com/?p=213. The excerpt below is their manifesto. I would be very grateful for comments, whether here or on the site. Thanks! Mike m...@asplake.co.ukhttp://positiveincline.comhttp://twitter.com/asplake Clients of RESTful web applications typically use prior knowledge of the target application’s structure to generate URIs. This approach is often very convenient, but much of this URI generation is hard-coded, and (worse) spread across client code. This introduces a high degree of coupling and makes clients unnecessarily vulnerable to server-side change. Steps to improve this situation: 1. In clients, centralise the generation of URIs and make the process driven by configuration data 2. Have servers publish the required configuration data - i.e. application metadata - in a readily understood format path-to provides the means for client applications to model web applications in terms of logical structure and URI mappings, and to interact with them through dynamically-generated application-specific APIs. described_routes supports an application metadata structure (published in JSON, YAML and XML formats) that can be consumed by path- to, and (helpfully) generates it automatically online or offline from the routes configured for a Rails-based application. The two libraries can be used separately or together - an JavaScript client is under independent development for example. Moreover, the underlying metadata format is framework-neutral; we have been careful not to “leak” Rails concepts into 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-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Activerecord.count calculation not reurning expected output
Hi, Im using the count calculations in activerecord, see below self.count(:id, :include = [:operating_systems], :group = 'operating_systems.name, operating_systems.id', This only returns 2 of the fields i need the id and the count: count_id operating_systems_name_operating_systems_id 49 1 30 2 If i run the sql this generates in the log on the database itself i get the follwoing SELECT count(DISTINCT products.id) AS count_id, operating_systems.name, operating_systems.id AS operating_systems_name_operating_systems_id FROM products LEFT OUTER JOIN product_operating_systems ON (products.id = product_operating_systems.product_id) LEFT OUTER JOIN operating_systems ON (operating_systems.id = product_operating_systems.operating_system_id) GROUP BY operating_systems.name, operating_systems.id So the above sql run on the DB i get 3 columns with the required information: count_id name operating_systems_name_operating_systems_id 49 PC 1 30 MAC 2 Is there any reason for this? Anybody got a better solution? JB -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Change onsubmit event key from return key ctrl-return
hi, use javascript and make new handle of kbd events. search google, I think you'll find a lot of examples t Geekyra wrote: Hello all, r there any way to change the return key in form single line input ? For example, I want the form to submit the process using ctrl-return key instead of return key because I want to use return key just to add another single line input, can it be done ? thanx all -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] accessing dll files from rails application
Hi Could anybody please suggest ways to access dll files from a rails application? Thanks in advance Sijo -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] I don't know super.... Sorry for my ignorance
Hi All, Today, when I debug, I found that I don't understand a very basic function super. code class User ActiveRecord::Base def self.columns puts here. @ret = super return @ret end end /code This return only one line of here.. It is very fine. However, when I called My codes are: code class User ActiveRecord::Base def self.columns puts here. super end end /code The return is what I expected - a list of columns in User, but this display 18 lines of here. in the console (the length of columns of my User is 17. What is the difference between the two super call? Thanks much! Arthur -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Flash notices are not accessible on next request
Tom Hoen wrote: 7stud -- wrote: Is there a second redirect in your code somewhere? That is a good thought. I was thinking along the same lines, so checked the console after issuing a request that should end with a displayed flash message and saw that there was only a single redirect. I also tried adding keep to the flash set statement, but alas, no message appeared. I am really stumped on this one. I had the same issue - it was because of the render_component plugin. Take that out and everything worked properly. However this might be something worth looking at too: https://rails.lighthouseapp.com/projects/8994/tickets/2200-session-support-broken Ta Luke -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] jRails problem
Hi, I am developing a Rails app and now I want to try some Ajax funcionality. I have a tracks list, and each track has a delete button. I have this operation implemented without Ajax with a redirection, and now I want to do it with Ajax. I am using JQuery and jRails. Here is my code: This is the delete function in my controller: def delete_track @track_id = params[:track_id] Track.delete(@track_id) respond_to do |format| format.html {redirect_to :action = 'index'} format.js end This is my html where the tracks list is: div id=musicalUnit h3 id=musicalUnitTileEstado de su unidad musical:/h3 ol %unless @musical_unit.nil? % % for track in @musical_unit.tracks % li id=track%= track.id %%= track.name % de strong%= track.album.singer.name %/strong %= link_to_remote(image_tag(delete.png, :alt = 'Borrar', :size = 16x16, :title = Borrar + track.name + de mi unidad musical), :update = musicalUnitTile, :url = {:controller = tracks, :action = 'delete_track', :track_id = track.id}) %/li % end % % end % /ol /div And this is my RJS code: page['#track' + @track_id].hide I want to hide the li element of the track after deleting it from the db. In my application.js I have this: jQuery.ajaxSetup({ 'beforeSend': function(xhr){xhr.setRequestHeader('Accept', 'text/javascript')} }) The problem is that after executing the delete action, the RJS code is called, but it is not interpreted. The page prints the RJS as if it was html code in the musicalUnitTile div, and I want to execute the RJS code as Javascript. What am I doing wrong? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Encrypting large amounts of text
Hi, Thanks for the responses. Sam, you mentioned that in your app, every user has his own pair of keys and the private key is stored encrypted with the users password. How many users does your system have? I was also considering trying to set something like this up, but I believe it will be far to much overhead for the number of users my system will have. As for limiting access to the private key (or password for that private key), I think that one good step here would be to store it seperately from both the application server and the database server. My concern here is that users will be requesting encrypted data fairly regularly, which means I will need to fetch the encrypted value from the DB, decrypt it, and provide the plaintext to the user (over an SSL connection). I am concerned about the type of overhead that retrieving the key/password from a remote server might be. Maybe this isn't the right approach for what I need to accomplish. In more detail, what I want is to allow users to be able to flag certain content to be encrypted within the DB. The system will have many users (possibly tens of thousands) that will be able to request to see this content when they are logged in (which will require the encrypted content to be retrieved, decrypted, and presented to the user). Still trying to iron this out. Any more thoughts on the issue? Thanks again, Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Code runs in development but not in test
I have some model code that runs fine in development environment but fails in the test environment. In test, the code always fails at the same point with: Mysql::Error: Duplicate entry '5-17' for key 'PRIMARY': INSERT INTO `accessibilities_namespaces` (`accessibility_id`, `namespace_id`) VALUES (17, 5) [0m accessibilities_namespaces is a join table for HABTM relationships. My logging suggests that ActiveRecord tries to insert the same record twice when run in test (but only in test!) which would explain the above error. I am sure that the code does not try to create the same record twice and in any case it runs fine in development mode. I have tried running the code using 'script/console test' and it fails here also. Though it does not fail when run in 'script/console [development]'. I suspect the problem does not lie with MySQL or ActiveRecord, but something to do with the differences between running in development vs test. Any thoughts appreciated. I'm baffled by this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Code runs in development but not in test
Is it failing while running one of your tests (possibly an error in the test) or while preparing for the test (possibly a problem with your fixtures)? Colin 2009/5/8 Lee lee.longm...@googlemail.com I have some model code that runs fine in development environment but fails in the test environment. In test, the code always fails at the same point with: Mysql::Error: Duplicate entry '5-17' for key 'PRIMARY': INSERT INTO `accessibilities_namespaces` (`accessibility_id`, `namespace_id`) VALUES (17, 5) [0m accessibilities_namespaces is a join table for HABTM relationships. My logging suggests that ActiveRecord tries to insert the same record twice when run in test (but only in test!) which would explain the above error. I am sure that the code does not try to create the same record twice and in any case it runs fine in development mode. I have tried running the code using 'script/console test' and it fails here also. Though it does not fail when run in 'script/console [development]'. I suspect the problem does not lie with MySQL or ActiveRecord, but something to do with the differences between running in development vs test. Any thoughts appreciated. I'm baffled by this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] ActionController::Caching::Sweeper not autoloading
Hi I've been following this issue on Lighthouse (https:// rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1977- actioncontrollercachingsweeper-autoloading-is-broken). I've since upgraded to 2-3-stable which contain's Josh's fix, but I'm still seeing the same error: `load_missing_constant': uninitialized constant ActionController::Caching::Sweeper (NameError) I've tried a variety of fixes as suggested in the Lighthouse comments, all to no avail. The only way I can get my app to start is by replacing: @@@ class MySweeper ActionController::Caching::Sweeper @@@ with @@@ require 'rails/actionpack/lib/action_controller/caching/sweeper' class MySweeper ActionController::Caching::Sweeping::Sweeper @@@ This is clearly wrong. Can anyone help? My environment.rb file is as follows, if this helps? Rails::Initializer.run do |config| %w(sweepers observers accounting).each do |dir| config.load_paths #{RAILS_ROOT}/app/#{dir} end config.cache_store = :file_store, #{RAILS_ROOT}/tmp/cache config.active_record.observers = :my_sweeper config.active_record.default_timezone = :utc config.action_controller.session_store = :active_record_store config.action_mailer.default_charset = utf-8 end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
On Thu, May 7, 2009 at 7:03 PM, zambezi b.but...@overhydration.org wrote: ... If I am going to use a three button group configuration, I need to have them all unchecked initially. And as the W3C spec I quoted indicates, you *can't count on that* if you're using HTML. Period. If none are explicitly checked by you, the user agent can check any one it wants as a default. Adding a third button doesn't change that. Perhaps you should explore using something like Flash/Flex for your interface? -- Hassan Schroeder hassan.schroe...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Code runs in development but not in test
Lee - On 8-May-09, at 9:53 AM, Colin Law wrote: Is it failing while running one of your tests (possibly an error in the test) or while preparing for the test (possibly a problem with your fixtures)? Colin to build on Colin's comment about your fixtures, if you're relying on the testing framework to wrap your tests in transactions, the database must support them - mysql myisam database tables do not - ie. if you're using myisam, your tables will not be cleaned out after every test - and you'd see this behavior J --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Code runs in development but not in test
Lee is using InnoDB. Chris. On 8 May, 15:02, Jodi Showers j...@nnovation.ca wrote: Lee - On 8-May-09, at 9:53 AM, Colin Law wrote: Is it failing while running one of your tests (possibly an error in the test) or while preparing for the test (possibly a problem with your fixtures)? Colin to build on Colin's comment about your fixtures, if you're relying on the testing framework to wrap your tests in transactions, the database must support them - mysql myisam database tables do not - ie. if you're using myisam, your tables will not be cleaned out after every test - and you'd see this behavior J --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Code runs in development but not in test
Initially it was failing when running the code from within a Cucumber step definition. In this step definition, I am implementing a Given step (in part) by calling a method of a model. This method is throwing the error. In summary, the step definition is as follows: Given ... do user = User.create!(...) member=Member.add_member_for_user(user) ! error thrown by this method ... end Having experienced the error within Cucumber, I then entered the same code into 'script/console test' i.e. user=User.create!(...) member=Member.add_member_for_user etc... The code raised an error again. If however I run the code in development or by using the development console or as a standalone Ruby program which makes use of ActiveRecord and my models, it runs fine. On 8 May, 14:53, Colin Law clan...@googlemail.com wrote: Is it failing while running one of your tests (possibly an error in the test) or while preparing for the test (possibly a problem with your fixtures)? Colin 2009/5/8 Lee lee.longm...@googlemail.com I have some model code that runs fine in development environment but fails in the test environment. In test, the code always fails at the same point with: Mysql::Error: Duplicate entry '5-17' for key 'PRIMARY': INSERT INTO `accessibilities_namespaces` (`accessibility_id`, `namespace_id`) VALUES (17, 5) [0m accessibilities_namespaces is a join table for HABTM relationships. My logging suggests that ActiveRecord tries to insert the same record twice when run in test (but only in test!) which would explain the above error. I am sure that the code does not try to create the same record twice and in any case it runs fine in development mode. I have tried running the code using 'script/console test' and it fails here also. Though it does not fail when run in 'script/console [development]'. I suspect the problem does not lie with MySQL or ActiveRecord, but something to do with the differences between running in development vs test. Any thoughts appreciated. I'm baffled by this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: what database field type should i use ??
I would also use a small join table with your sets ... so your users can add properties on the fly. On May 8, 9:13 am, Vipin sh.vi...@gmail.com wrote: On May 7, 8:09 pm, Billee D. william.dod...@gmail.com wrote: Sometimes it''s a matter of taste or design constraint, but why not use a small join table and a foreign key? ENUM is also a great choice, as these guys have pointed out, but sometimes there is a bit of overhead -- but you shouldn't worry about that until it becomes an issue. Personally, I find it easier to maintain a simple join table and FK relationships than to mess with ENUM field types. I don't know if this is still applicable, but it seems like there is a bit of data massaging in Rails for the ENUM type (Rails converts it internally to VARCHAR): http://lists.rubyonrails.org/pipermail/rails/2005-January/001536.html I like to let the database do as much work as it can, :-) HTH! Billee D. On May 7, 4:43 am, Vipin sh.vi...@gmail.com wrote: in a database table if there is a field which has a certain set of fixed values. for example staus = {Single, Married, Divorced } OR state = {California, Albama, Olaska ...} so what should be preferred way out of the following for storing the values 1. Keep the field as string(Rails) VARCHAR(MySQL) itself and while showing the field just show the field value. 2. Keep the field internally as a code like {:california = 01, :albama = 02, washington = 03 } but while showing the state show only the corresponding state. By using option 2, a certain disadvantage is extra computation time required to find out corresponding state name based on code when showing the state field to user. But an advantage could be in terms of smaller database. In my opinion, saving 01 as an integer could save significant space than storing california if number of records happen to be in tens of thousands . please suggest ?? vipin But Bilee, if we use another table and do the mapping through foreign key won;t it be even poorer as we will be making 2 SQL queries to access the same record. which we are doing in one SQL query in above two methods. But i ll certainly check the link provided. vipin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Flash Filereference and Rails - getting http 422
Anyone know what the answer might be? Or an up to date link that explains? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: what database field type should i use ??
The question isn't really a performance issue, but rather one of customization. If users are likely to need to add values to an enumeration, (example: category for a blog post), then a lookup table is a good idea. If the values are substantially unlikely to change (see your examples - marriage status and state) then there's not a lot to be gained by complicating the DB. --Matt Jones On May 7, 3:43 am, Vipin sh.vi...@gmail.com wrote: in a database table if there is a field which has a certain set of fixed values. for example staus = {Single, Married, Divorced } OR state = {California, Albama, Olaska ...} so what should be preferred way out of the following for storing the values 1. Keep the field as string(Rails) VARCHAR(MySQL) itself and while showing the field just show the field value. 2. Keep the field internally as a code like {:california = 01, :albama = 02, washington = 03 } but while showing the state show only the corresponding state. By using option 2, a certain disadvantage is extra computation time required to find out corresponding state name based on code when showing the state field to user. But an advantage could be in terms of smaller database. In my opinion, saving 01 as an integer could save significant space than storing california if number of records happen to be in tens of thousands . please suggest ?? vipin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: export to excel
KARTHIKEYAN RANGASWAMY wrote: try for the spreadsheet-excel gem .you can google for spreadsheet-excel gem.You will get the sample code for it.if you dont get it just mail me i will provide you the sample code Hi Karthik, Can you guide me how to export data's to Excel sheet, which i am taking it from Webpage; My code . .code continues elements = get_text_fields(ie) elements.each{|e| p 'Name - ' + e.name p 'Value - ' + e.value code continues after executing i am getting Value, Name; Now i need to export to Excel, Name as Header and Value in each cells (rows and columns) -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
Hi Hassan, Do you have any idea of what behavior to expect if I explicitly set each radio button's checked property to unchecked? What will take precedence according to W3C specs (or is this all just another browser war casualty)? %= f.radio_button(:hypotonic_saline, nil, :checked = unchecked) % Thanks, Bill On May 8, 8:58 am, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Thu, May 7, 2009 at 7:03 PM, zambezi b.but...@overhydration.org wrote: ... If I am going to use a three button group configuration, I need to have them all unchecked initially. And as the W3C spec I quoted indicates, you *can't count on that* if you're using HTML. Period. If none are explicitly checked by you, the user agent can check any one it wants as a default. Adding a third button doesn't change that. Perhaps you should explore using something like Flash/Flex for your interface? -- Hassan Schroeder hassan.schroe...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: is there simpler way to export html within xml
Way to be appreciative of someone trying to help you. Good luck with that. On May 7, 9:50 pm, Marnen Laibow-Koser rails-mailing-l...@andreas- s.net wrote: Todd Fox wrote: thanks Marnen and everyone, do you know of any examples or something i can have a look at to get my head around it? What's to get your head around? Just pretend your XML file is an HTML page, and proceed accordingly with your favorite template language (ERb, Builder, Haml, Markaby, whatever). There's no new concept involved. Best, -- Marnen Laibow-Koserhttp://www.marnen.org mar...@marnen.org -- Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: is there simpler way to export html within xml
My bad MLK. On May 8, 11:40 am, Osiris mchugh...@gmail.com wrote: Way to be appreciative of someone trying to help you. Good luck with that. On May 7, 9:50 pm, Marnen Laibow-Koser rails-mailing-l...@andreas- s.net wrote: Todd Fox wrote: thanks Marnen and everyone, do you know of any examples or something i can have a look at to get my head around it? What's to get your head around? Just pretend your XML file is an HTML page, and proceed accordingly with your favorite template language (ERb, Builder, Haml, Markaby, whatever). There's no new concept involved. Best, -- Marnen Laibow-Koserhttp://www.marnen.org mar...@marnen.org -- Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Testing alternate css for printing
I am using an alternate style sheet for printing, loading it via %= stylesheet_link_tag 'print', :media = :print % which is working as expected. The problem is with testing, I would like to test that the layout is working correctly, in my controller functional tests, but I cannot see how to do this as, if I understand correctly, the style sheet selection change is made by the browser. I can check, for example, that items to be hidden are enclosed in divs of the appropriate class so that they should be hidden, but I cannot check that they actually will be hidden when printing. Is there any way to do this? Any suggestions will be appreciated. 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-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
On Fri, May 8, 2009 at 9:37 AM, zambezi b.but...@overhydration.org wrote: Do you have any idea of what behavior to expect if I explicitly set each radio button's checked property to unchecked? Again, it's up to the user-agent how it handles this situation. I'd just suggest 1) either accepting having a visible no preference choice (and make it visually obvious that it's a default) or 2) trying what you suggest and testing thoroughly in all the standard browsers. You'll have to decide how long that #2 list is for your audience :-) HTH, -- Hassan Schroeder hassan.schroe...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Testing alternate css for printing
Colin Law wrote: [...] I cannot check that they actually will be hidden when printing. Is there any way to do this? Several ideas come to mind. * Use JavaScript to check that display:hidden is properly set. * Generate a PDF file with the browser's Print command, then parse it somehow. * The same, but start with a reference rendering, get a checksum from the reference rendering, and raise a flag if the checksum changes. I hope these are a shove in the right direction... Any suggestions will be appreciated. Colin Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
On May 7, 12:46 pm, zambezi b.but...@overhydration.org wrote: In others words allow the user to undo a response and return the control to a null state (nothing selected). Why not provide an Clear button that deselects all the radio buttons in the group? That's simple Javascript, and I wouldn't call it a workaround. It explicitly provides the functionality that you appear to want -- a mechanism for a user to undo a response. Seems like a much simpler and more deft solution to the problem than trying to rejigger the semantics of radio buttons. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: I don't know super.... Sorry for my ignorance
Hi All, Today, when I debug, I found that I don't understand a very basic function super. code class User ActiveRecord::Base def self.columns puts here. @ret = super return @ret end end /code This return only one line of here.. It is very fine. However, when I called My codes are: code class User ActiveRecord::Base def self.columns puts here. super end end /code The return is what I expected - a list of columns in User, but this display 18 lines of here. in the console (the length of columns of my User is 17. What is the difference between the two super call? These two methods should both print the line here. to standard output before they return an array of column objects. I'm not sure why you're getting different results. Note that the super keyword has different semantics in Ruby than for example Java -- I'd suggest consulting the Pickaxe or Ruby for Rails if you're confused about its behaviour. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Flash Filereference and Rails - getting http 422
Hmm. I think it may be something with the Authenticity Token. I think I need to bypass 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-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
Hmmm... I can use a Javascript solution and assume/hope the worlds' browsers are all JS enabled. Or use a non-JS solution and assume/hope the browsers/versions I don't test for will see things the same way. Either way I don't see things degrading nicely. My bias (rational or otherwise) is against Javascript. But if I throw in the towel and go that direction, then I think I would consider creating some sort of checkbox group and use JS to make sure that only one checkbox per group could be selected. Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Confused about REST and custom actions
Robert, This makes more sense now. Thanks for the explanation! If anyone is interested, I decided to do it this way (from Agile Web Development with Rails book) : map.resources :widgets, :collection = { :popular = :get, :heaviest= :get } With this I can still add the custom method to my widgets controller. This approach makes the most sense to me considering how my application is organized. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: accessing dll files from rails application
Colin Law wrote: In what sense do you want to access the dll, and are we talking here client side or server side? I would hope the OP is interested in accessing a dll on the server-side. I would hope that would not be possible to do client-side. That would be mean there would have to be a very bad security hole in the client's web browser. Assuming it's happening server-side, the OP's author should realize that do this would render the open, and cross-platform nature of Ruby on Rails moot, effectively binding his application to run on Microsoft Windows only. It is, however, common to embed native C code in Ruby applications. This happens a lot with Gems. Do this requires compilation for the hardware running the Ruby application. This would, of course, require having the source code used to create the dll available. In my opinion it would be much better to create a web service that exposes a REST API. That API could then be used to integrate the functionality of the dll with the Rails application. This would decouple the two system and allow the Rails application to run on any hardware and access the web service that depends on the dll. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Testing alternate css for printing
2009/5/8 Marnen Laibow-Koser rails-mailing-l...@andreas-s.net Colin Law wrote: [...] I cannot check that they actually will be hidden when printing. Is there any way to do this? Several ideas come to mind. * Use JavaScript to check that display:hidden is properly set. I cannot see how to integrate this into an automated test. * Generate a PDF file with the browser's Print command, then parse it somehow. * The same, but start with a reference rendering, get a checksum from the reference rendering, and raise a flag if the checksum changes. The same question here, I would like this to be integrated into an automated test, would it be possible to invoke a browser from the rails test environment to do the print to PDF? Would I want to? Maybe I am asking the impossible, or at least the 'not worth the effort'. I hope these are a shove in the right direction... Any suggestions will be appreciated. Colin Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] div_for and RJS
Do you have to use an activeRecord object for div_for? Perhaps I'm taking the wrong approach for dynamic divs so far my education: 1. id= , is fine for just one div and prototype activity in an RJS (I got this to work) 2. class= , another option, but I don't see how it can be used 3. div_for , a helper that uses ActiveRecord objects to come up with multiple divs Below: code that is my best guess for how to proceed, but it doesn't do everything it is supposed to do: script src='http://pastie.org/472556.js'/script script src='http://pastie.org/472563.js'/script -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: div_for and RJS
the code is here http://pastie.org/472556 and here http://pastie.org/472563 sorry about the extra bits -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Flash Filereference and Rails - getting http 422
K I figured out how to fetch and send the AuthToken.. It's still now working. Anyone have any idea, or a resource for Flash file uploading to Rails 2.x? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: div_for and RJS
The class will not work for a rjs call.. html class elements are not unique by design so that is not a good idea anywho... Here is a good description for div_for http://apidock.com/rails/ActionView/Helpers/RecordTagHelper/div_for It's just a way to create a div that has something todo with the record that you have. So if you have a @user object with id of 1 you would get id=user_1 for the div. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Flash Filereference and Rails - getting http 422
oops, I meant still NOT working** Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Gem path problems w/ Passenger+Apache2
Anyone else having a dickens of a time getting Passenger+Apache2 to recognize the gem path? Many things that work well w/ webbrick just don't work at all with P+A - require fails. Here are my versions: gem 1.3.3 (from source, partly in attempt to get this working...) Rails 2.3.2 Jaunty Jackalope (32-bit) passenger 2.2.2 Apache 2.2.11 Thanks, m --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Gem path problems w/ Passenger+Apache2
On Fri, May 8, 2009 at 6:13 PM, Marc Byrd dr.marc.b...@gmail.com wrote: Anyone else having a dickens of a time getting Passenger+Apache2 to recognize the gem path? Many things that work well w/ webbrick just don't work at all with P+A - require fails. Here are my versions: gem 1.3.3 (from source, partly in attempt to get this working...) Rails 2.3.2 Jaunty Jackalope (32-bit) passenger 2.2.2 Apache 2.2.11 Thanks, m Can you provide some additional details about the platform you're using and the actual error message? -Conrad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Gem path problems w/ Passenger+Apache2
Platform - Ubuntu, 32-bit on EC2, jaunty jackalope On line that says require 'cloud_cache' it says file not found. Note that in order to get require 'simple_record' to load properly I had to chown www-data:www-data on its files. I did the same on cloud_cache files but no joy. Again, all work perfectly well under webbrick. thanks, m On Fri, May 8, 2009 at 6:17 PM, Conrad Taylor conra...@gmail.com wrote: On Fri, May 8, 2009 at 6:13 PM, Marc Byrd dr.marc.b...@gmail.com wrote: Anyone else having a dickens of a time getting Passenger+Apache2 to recognize the gem path? Many things that work well w/ webbrick just don't work at all with P+A - require fails. Here are my versions: gem 1.3.3 (from source, partly in attempt to get this working...) Rails 2.3.2 Jaunty Jackalope (32-bit) passenger 2.2.2 Apache 2.2.11 Thanks, m Can you provide some additional details about the platform you're using and the actual error message? -Conrad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Gem path problems w/ Passenger+Apache2
Are you using passenger's ruby? Seems I remember reading that if you are you need to install gems via both the system-ruby and the passenger-ruby as they end up in different spots and passenger-ruby only looks for them in it's own directory heirarchy. -p On May 8, 2009, at 6:58 PM, Marc Byrd wrote: Platform - Ubuntu, 32-bit on EC2, jaunty jackalope On line that says require 'cloud_cache' it says file not found. Note that in order to get require 'simple_record' to load properly I had to chown www-data:www-data on its files. I did the same on cloud_cache files but no joy. Again, all work perfectly well under webbrick. thanks, m On Fri, May 8, 2009 at 6:17 PM, Conrad Taylor conra...@gmail.com wrote: On Fri, May 8, 2009 at 6:13 PM, Marc Byrd dr.marc.b...@gmail.com wrote: Anyone else having a dickens of a time getting Passenger+Apache2 to recognize the gem path? Many things that work well w/ webbrick just don't work at all with P+A - require fails. Here are my versions: gem 1.3.3 (from source, partly in attempt to get this working...) Rails 2.3.2 Jaunty Jackalope (32-bit) passenger 2.2.2 Apache 2.2.11 Thanks, m Can you provide some additional details about the platform you're using and the actual error message? -Conrad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] periodically autosave form
Would someone show how to implement a periodical save of a form in the background? Same kinda thing that gmail does. I would like to autosave a form ajax wise so a technician in the field would have it saved off in case of a wireless disconnect while filling out a form. thanks. I would guess on doing the periodically call remote but how do you submit the form? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: periodically autosave form
A caveat, It has to be done with the form already having been created. So doing an observe form with a form id will not work as the form id id being generated by rails as it is in edit mode. On May 8, 9:38 pm, Me chabg...@gmail.com wrote: Would someone show how to implement a periodical save of a form in the background? Same kinda thing that gmail does. I would like to autosave a form ajax wise so a technician in the field would have it saved off in case of a wireless disconnect while filling out a form. thanks. I would guess on doing the periodically call remote but how do you submit the form? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: periodically autosave form
I am not sure about your situation, but I would use observe_form set and :frequency to seconds at which changes to this field will be detected. This should work with the existing form. See the documentation. http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.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-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] XMLRPC raw_post getting run through Hash#from_xml
Im trying to create an api, and Im having trouble getting ActionController to not run the raw post data through Hash#from_xml (request.parse_formatted_request_parameters) for the XMLRPC post data. I essentially want it to run through XMLRPC::XMLParser::REXMLStreamParser.new.parseMethodCall(request.raw_post). However, I can't figure out a clever, clean way to get request.request_parameters to not run since it can run as early as the dispatcher, which will essentially trigger Hash#from_xml on that call before it even gets into the scope of the controller. Anyone experience a problem like this before? Granted I can just let Hash#from_xml run and add a couple msec's to every call for no reason, but there should be a way around it. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] can't get a simple partial to work !...@#!$!!
class StoreController ApplicationController def index @array = [1, 2, 3] end end index.html.erb - render(:partial = test, :object = @array) _test.html.erb % for num in test % div%= num %/div % end % When I enter the url: http://localhost:3000/store in my browser, this is the output: - NoMethodError in Store#index Showing app/views/store/_test.html.erb where line #1 raised: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each Extracted source (around line #1): 1: % for num in test % 2: div%= num %/div 3: % end % - The error is saying that test is nil. A ruby program: array = [1, 2, 3] for num in array puts num end --output:-- 1 2 3 My understanding was that when you write: render(:partial = test, :object = @array) then inside the file _test.html.erb a local variable called test is assigned the object @array. But in my application, @array is not nil--it was assigned the array [1, 2, 3] in the controller. Why won't rails relent and loop through the array like I am commanding it to do? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: can't get a simple partial to work !...@#!$!!
I figured it out. I wasn't careful about where I was putting render(). I variously tried putting it in index.html.erb and in the layout (layouts/store.html.erb). I ended up with render() in both files: one specifying :object and one using :collection. !...@#$!@#...@#$#!@@#...@# -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: accessing dll files from rails application
Hi Thanks for the alternative approcah But I would like to know how can I access a dll from rails?(Suppose from server side) Sijo -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: can't get a simple partial to work !...@#!$!!
views/store/index.html.erb: %= render(:partial = layouts/test, :object = @array) % views/layouts/_test.html.erb: % for num in test % div%= num %/div % end % On May 8, 5:59 pm, 7stud -- rails-mailing-l...@andreas-s.net wrote: class StoreController ApplicationController def index @array = [1, 2, 3] end end index.html.erb - render(:partial = test, :object = @array) _test.html.erb % for num in test % div%= num %/div % end % When I enter the url: http://localhost:3000/store in my browser, this is the output: - NoMethodError in Store#index Showing app/views/store/_test.html.erb where line #1 raised: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each Extracted source (around line #1): 1: % for num in test % 2: div%= num %/div 3: % end % - The error is saying that test is nil. A ruby program: array = [1, 2, 3] for num in array puts num end --output:-- 1 2 3 My understanding was that when you write: render(:partial = test, :object = @array) then inside the file _test.html.erb a local variable called test is assigned the object @array. But in my application, @array is not nil--it was assigned the array [1, 2, 3] in the controller. Why won't rails relent and loop through the array like I am commanding it to do? -- Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Differences between console [development] and console test?
One of my model code methods is throwing an error when run using script/console in test but not in development. I'd be grateful if someone can tell me the differences between the two, beyond the database that they connect to. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: can't get a simple partial to work !...@#!$!!
Rick Lloyd wrote: views/store/index.html.erb: %= render(:partial = layouts/test, :object = @array) % views/layouts/_test.html.erb: % for num in test % div%= num %/div % end % Sorry, I don't know what that means, and I still can't solve my original problem, which led to the test code in my op. Here is what I have now: class StoreController ApplicationController def index @products = Product.find(:all) end def add_to_cart @cart = [1, 2, 3] end end layouts/store.html.erb --- !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 / title% @page_title || Store %/title %= stylesheet_link_tag 'scaffold', 'store2.css' % /head body div%= render(:partial = cart, :object = @cart) %/div /body /html views/store/_cart.html.erb --- % for num in cart -% div%= num %/div % end % When I go to http://localhost:3000/store in my browser, I get this: - NoMethodError in Store#index Showing app/views/store/_cart.html.erb where line #1 raised: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each Extracted source (around line #1): 1: % for num in cart -% 2: div%= num %/div 3: % end % Trace of template inclusion: app/views/layouts/store.html.erb -- -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---