search for: to_

Displaying 20 results from an estimated 1207 matches for "to_".

Did you mean: to
2006 Mar 01
15
Is there a perl equivalent of .= in ruby/rails??
I want to make a for loop that concats strings onto a variable: html .= var1 + "this is a test" + whatever What is the syntax that does this in ruby/rails? Also, is there a ''print'' method in ruby? Because when I try to use render_text it will only let me use this once. -- Posted via http://www.ruby-forum.com/.
2006 Mar 16
3
Passing function names from string variables
...ure out if there is a way to pass in the string value of a variable as the name of a method. For example, I would like to do something like: def sort_obj_by_uid(objects,@attr) @tmparray = Array.new @tmphash = Hash.new for object in @objects if ! @tmphash.has_key?(object.@attr.to_s) @tmphash[object.@attr.to_s] = Array.new end @tmphash[object.@attr.to_s].push(object) end end Where the method name is the @attr value. -- Leah Cunningham : d416-585-9971x692 : d416-703-5977 : m416-559-6511 Frauerpower! Co. : www.frauerpower.com : Toronto, ON Canada
2006 Jun 28
2
Assign CSS class to Link to Remote
I''m trying to get link_to_remote to assign a CSS class to the link it generates. My code is as follows: <%= link_to_remote "Show Full Info", :update => "fullcontact" + reparray.last.to_s, :url => "/cm/full_contact/" + reparray.last.to_s, :classname => "contactlink" %>...
2007 Apr 11
0
Fwd: [ mocha-Bugs-6416 ] Mock objects shouldn''t define #to_s
---------- Forwarded message ---------- From: noreply at rubyforge.org <noreply at rubyforge.org> Date: 11-Apr-2007 15:07 Subject: [ mocha-Bugs-6416 ] Mock objects shouldn''t define #to_s To: noreply at rubyforge.org Bugs item #6416, was opened at 2006-10-31 15:34 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=7477&aid=6416&group_id=1917 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: James Adam (lazyatom...
2006 Nov 23
2
to_s
I was toying around with adding a to_s function to wxPoint (and probably to some other classes). I''m wondering if this is a good idea or not and if so, is it best to use %extend or put it into something like wxSugar or the ruby parts of wx? My initial implementation is: %extend wxPoint { VALUE to_s() { char buffe...
2007 Mar 29
1
Extending the to_s method
Hi! I''m developing an localization plugin (just for my own purposes) and I wanted to extend the to_s method for the Time class. What I want to do: when someone does date.to_s(:short) that a localized version of the :short date is displayed. But I don''t know how to accomplish this. I know have this: class Time def to_s(option) print option.to_yaml ''lalo'' en...
2009 Jan 13
1
ROR - Excel Export Example
...ou the basic idea ------ def export require ''win32ole'' @sort_by = ''last_name'' current_user = ''steve'' @records = Contact.find( :all, :conditions => ["created_by = ?", self.current_user.login.to_s] #, #:order => @sort_by ) # Creates OLE object to Excel excel = WIN32OLE.new("excel.application") # Create the chart excel[''Visible''] = TRUE; excel.DisplayAlerts = false #Supress''s Excel warnings workbook...
2006 Jul 19
6
ActiveRecord::RecordNotSaved - bizarre behaviour.
...rdNotSaved): ... As you can see, there''s no INSERT SQL generated, which is the root cause of the problem. In my user model, I have the following call back: def before_create self.password = Digest::SHA1.hexdigest(self.password) self.rsskey = Digest::SHA1.hexdigest(Time.now.to_s+"_"+String.rand(15)) self.otp = Digest::SHA1.hexdigest(Time.now.to_s+"_"+String.rand(15)) self.verified = false #logger.debug("--> "+self.to_s) #This is the magic line!! end The really really black magic part is that, if I comment the logging s...
2006 Feb 13
7
Concatenation
I have this: <%= @tech_standard.category + " " + @tech_standard.point + "." + @tech_standard.subpoint %> I get this error: cannot convert Fixnum into String point and subpoint are number. How do I concatenate those values? Seth Buntin Web Resources Coordinator Kentucky Academy of Technology Education Murray State University --------------
2008 Apr 11
4
request.params causing errors
Hello, I have a rhtml file that goes through the request.params. One of my test generates that file, but rspec pops an error saying : undefined method ''params'' for ... I''m not sure what to do with this, since request.params actually works with rails. Any idea? Thank you Olivier Dupuis -------------- next part -------------- An HTML attachment was scrubbed... URL:
2008 Dec 13
2
Need Help in converting php encryption decryption code to ruby on rails
...t(plain_text,password,iv_len=16) plain_text +="\x13" n=plain_text.size if(n%16) plain_text +="\0"*(16-(n%16)) end i=0 enc_text=get_rnd_iv(iv_len) enc='''' pass='''' for i in 0..password.size-1 pass +=password[i].to_s(2) end for i in 0..enc_text.size-1 enc +=enc_text[i].to_s(2) end intervalue=(pass.to_i^enc.to_i).to_s iv=password^enc_text.split(0,512) iv=intervalue[0,512] while ( $i < $n ) { $block = substr( $plain_text, $i, 16 ) ^ pack( ''H*'', md5 ( $iv...
2006 Apr 20
5
Noobie problems with helper
I have the following helper method in application_helper.rb: def format_date(date) day = to_s(date.day) month = to_s(date.month) time = to_s(date.time) date = day + "/" + month + " - " + time return date end I am trying to call this method in a view like this: <%= format_date(bounty.created_on) %> create_on is a timestamp in mysql. I am getti...
2006 Mar 19
2
Functional Testing
Hey all, I have a many-to-many relationship (Questions has_and_belongs_to_many Answers), and when I destroy the Question (the one) I also destroy all the Answers (the many). Since the following doesn''t seem to work for has_and_belongs_to_many: class Question < AR::Base... has_and_belongs_to_many :answers, :dependent => :destroy end I have this embedde...
2006 Jan 07
2
can store array or hash in cookies?
...ies_first cookies[:chef] = {:value => ["first", "second"], :expires => Time.local (2020)} render_text ":)" end def check_cookies_second begin render_text "cookies class is: " + cookies[:chef].class.to_s + " value: " + cookies[:chef] rescue Exception => e render_text "Why this don''t work? exception: " + e.to_s end end Started server: get check_cookies_first ---> ":)" get check_cookies_second ---> "cookies class is:...
2006 Jan 13
0
Controller part of in-place editing
...ding, and want to add in-place editing to an admin section. I think I may have the view part working right (at least, the editor pops up as expected) with this in my view: ### <% for link in @links %> <tr> <td> <div id="<%= ''url'' + link.id.to_s -%>"><%= link.url %></div></td> <%= in_place_editor (''url'' + link.id.to_s, :url => {:action => ''edit_inplace''} ) %> <td> <div id="<%= ''title_'' + link.id.to_s -%>">&...
2006 Jul 31
2
is it possible to make to_xml use underscore instead of dash?
Hi all, I am getting ActiveRecord to produce XML with render :xml => @user.to_xml However, on the client end it is a bit annoying for me to deal with attributes like first-name. I would much rather have first_name. Is there any way for me to turn off the behavior of converting _ to -? This seems to be done by a call to dasherize inside the to_xml of ActiveSupport::CoreExt...
2006 Mar 22
2
What is wrong in this method??????
Hi, This is my definition of method "add_to_cart" ======================= def add_to_cart count=params[:product][:count] while count.to_i>=0.to_i if params[:product][''dem_quantity''+count.to_s]=="" else @product = Product.find(params[:product][''product_id''+co...
2006 Jun 20
9
secure downloads
Has anyone had any success with the mongrel_secure_download gem? I keep getting "connection reset" errors. -- Cheers, Kevin
2006 Apr 19
1
AJAX - update item forms problem
...error_list_<%= workout.id %>"> <%= error_messages_for ''workout'' %> </div> </div> <%= form_remote_tag :url => { :action => ''update'', :id => workout }, :html => { :id => "workout_form_#{workout.id.to_s}" } %> <% @workout = workout %> <%= render :partial => ''update_form'' %> <%= end_form_tag %> </td> </tr> workouts_controller.rb ---------------------- def show_workout_update_form @workout_id = params[:id] end def hide_w...
2008 Jun 18
1
Vpim gem
...etbrink <joost at joopp.com> wrote: > Hi Sam Roberts, > First of all. Thanks for the Vpim gem. We use it at www.yelloyello.com and > it works great. I''m glad to hear that. > We''ve only encountered the following error: > # NoMethodError (undefined method `to_str'' for []:Array): > # > /usr/local/lib/ruby/gems/1.8/gems/vpim-0.619/lib/vpim/rfc2425.rb:256:in > `encode_text'' > Maybe it should state .to_s instead of .to_str ? I don''t have the code in front of me, but you are trying to encode a text field, it seems...