search for: my_object

Displaying 20 results from an estimated 26 matches for "my_object".

2005 Dec 17
2
Storing an object in the db
...t a working response. I''d like to store an object inside a binary field in my db. So I''d have a class like this class MyAwesomeClass def do_something_awesome ... end end then class MyRecord < ActiveRecord::Base end the table my_record would have a binary field, my_object, that would store an object of MyAwesomeClass. So I could do: r = MyRecord.new r.my_object = MyAwesomeClass.new r.reload r.my_object.do_something_awesome I saw that there''s a serialize helper, where I''d put this in my AR class: class MyRecord < ActiveRecord::Base serialize...
2007 Dec 08
3
Uploading photos using facebook & attachment_fu
Hi All, I''m trying to use a form to upload a photo that I will save using attachment_fu. I''m very new to Facebookr so I apologize if this is covered somewhere, but I''m kind of stumped. Here''s what I''m doing now: <% facebook_form_for(:my_object, :url => { :action => ''upload_photo'', :id => params[:id] }, :html => { :multipart => true }) do |f| -%> <%= radio_button_tag ''my_object[my_param]'', "value" %> <%= file_field_tag "photo[uploaded_data]" %> <%...
2010 Mar 24
2
Mock "Consent_6335" received unexpected message :marked_for_destruction? with (no args)
I have a mock object (Person) that is associated with another object (my_object) through a belongs_to association. When I check whether my_object is valid (my_object.should be_valid), I am getting an error like the following: Mock "Person_6338" received unexpected message :marked_for_destruction? with (no args) Checking the list of methods on the mock, "marked...
2006 Feb 16
21
RoR VS Rails ???
I didn''t get a chance to go to this meeting debating WebObjects Vs Rails, but here''s a report about it: http://desperatepundit.com/blog/cremes/technology/2006/02/15/WebObjects-versus-Ruby-On-Rails.html I don''t get what he''s saying, hand coding the model? yeah, you COULD ... but what about script/generate ??? And is that so what he said about security? --
2006 May 09
1
Reusing a model to form and link_to.
...Inside my app I have a form which contains user information. Sometimes a have a form with a text_field as above: <%= form_remote_tag(:html => { :action => url_for(:controller => "my_controller", :action => "my_action") }) %> <%= text_field(''my_object'', ''my_parameter'', :maxlength => ''30'' )%> <%= submit_tag "Send"%> <%= end_form_tag %> In the controller I retrive the information using: @my_value = params[:my_object][:my_parameter] OK. In other parts I have a link_t...
2005 Oct 16
13
More than one parameter with link_to_remote
...that seems quite strange to me. Here''s the code: link_to_remote ''some text'', :update => ''form'', :method => ''get'', :url => { :action => ''my_action'', :id => @my_object, :extra_param => ''my_extra'' } The URL I got is: ''/controller/my_action/32?extra_param=my_extra'' (32 is @my_object''s id) but params[:extra_param] contains ''my_extra?''. Why that extra question mark? I think I''m missing som...
2007 Jun 23
4
inverse examples? (should fail)
...e old behaviour should change. Imagine changing the "it" method to perhaps "not" or "old" or "removed"... The behaviour would be to raise a spec error if the example DOES NOT fail. So if it "should do something that''s been deprecated" do my_object.should_receive(:deprecated_message) action end passes, than old "should do something that''s been deprecated" do my_object.should_receive(:deprecated_message) action end ought to fail. It seems like this might be a good first line of defense when starting a big refactor....
2006 Jul 23
4
Anything like with_scope for ActionController?
...by the actions. I currently have this working with routes, however I need to tack on an extra parameter to all the url generating functions (url_for, form_start_tag, named_route_url...) to get the mapping to pick up the custom URL parameter. Having to remember to append :short_name=>@my_object.short_name (with or without to_param magic), is getting annoying and the repetition is getting ugly. Is there anything like ActiveRecord''s with_scope function to "bind" this extra parameter once and make ActionController smart about propagating the extra parameter everywhe...
2010 Jul 08
3
Testing equality
Hello How can I test equality with two objects when they include some attribute that is BigDecimal? if I make something like this: it "should ...whatever" do obj = Factory.create(:my_object) ... MyObject.first.should == obj end. FAILS This fails because the object expected is different from the object gotten, and the only difference are the BigDecimal attributes, that are different objects, even though they have the same value. Thanks. -- Posted via http://www.ruby-forum.com/.
2008 Mar 03
9
mutiple select
Hello: How do i make a mutiple select list for "nomodel" objects?I made that by using something like:<select name="" multiple="mutiple"><%=option groups collection for select(....)-%></select>.But when i select mutiple items and submit them,I can only get one selected item? Who can help me? -- Posted via http://www.ruby-forum.com/.
2006 Aug 10
6
save without commit ?
How do I get ''save'' to execute without commit? I have tried: ActiveRecord::Base.connection.begin_db_transaction # do some stuff that doesn''t issue a database COMMIT statement # then: @myObject.save # this issues a COMMIT but it shouldn''t! Shouldn''t it wait until I''ve called: ActiveRecord::Base.connection.commit_db_transaction ? what am
2007 Mar 24
15
State Based vs. Behaviour Based Spec/Testing
I''ve notice that a project like Rubinius has both a spec & a test directory. Rspec has only a spec directory. Obviously I support BDD, but isn''t there also a place for state based/verification testing? I sometimes sense that I *do* want to practice Test Driven Development. That is, I want some assurance that my production code will run as intended. But I also
2016 Oct 13
2
RFC: General purpose type-safe formatting library
...#39;s no other way > > > Maybe the problem is using a string to format this in the first place. > > For example, you could wrap the object you want to print with an adaptor > in charge of padding to the right till you reach the column width. > > format(“{0}”, rPad(col_width, my_object)); > > > FWIW I do think that literal format strings will handle 90% or more of > uses. I just don't see the benefit of needlessly banning the other cases. > Because all that's going to happen is someone is going to resort to using > snprintf etc, which is exactly the pro...
2006 Jan 04
2
collection_select with array as source
...with a simply array as the source of the collection. My array looks like this: STATES = ["Alabama", "Alaska", "Texas"] and it is stored in my environment.rb I can''t figure out the syntax for the collection_select in this situation... collection_select("my_object", "state", what goes here??? ) I just need the state name to go on both the value and the label field of each <option> I would be grateful for any help. Thanks, Shelby -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org...
2006 Jul 13
1
error_messages_for
I can''t seem to figure out how to validate a few fields some1 please help me out model--------- class Record < ActiveRecord::Base validates_presence_of :sw, :flex end controller------------ class RecordController < A;;icationController def new @record = Rrecord.new @product = Product.find(params[''product_id'']) end def create
2016 Oct 13
2
RFC: General purpose type-safe formatting library
...#39;s no other way > > > Maybe the problem is using a string to format this in the first place. > > For example, you could wrap the object you want to print with an adaptor > in charge of padding to the right till you reach the column width. > > format(“{0}”, rPad(col_width, my_object)); > FWIW I do think that literal format strings will handle 90% or more of uses. I just don't see the benefit of needlessly banning the other cases. Because all that's going to happen is someone is going to resort to using snprintf etc, which is exactly the problem I'm trying to s...
2008 Sep 17
2
AR: add attribute to model
...a simple example: We have an object that has a start and a stop attribute, i.e. columns in the table. Now I want to know the distance, but directly via an readable attribute. Class Something attr_accessor :distance def initialize @distance = self.stop-self.start end end However, if I use my_object.distance, it returns nil... What am I doing wrong? P.S. I also tried def initialize(distance) - but figured that only makes sense if I specifically create a new object, not if the attribute is created from within the class. Didn''t work either, anyway. Cheers, Marc -- Posted via http:/...
2016 Oct 12
5
RFC: General purpose type-safe formatting library
You get compile time checking automatically when we can use c++14 though. If you use it with a string literal, you'll get compile time checking, otherwise you won't. Here's a different example though. Suppose you're writing a tool which prints formatted output, and the field width is specified by the user. Now you NEED to build the format string at runtime, there's no other
2009 Oct 20
8
Stub that returns hash values
Is it possible to create a stub that returns hash values. For example I would like to convert this: @siteItem = stub(''plmSiteItem'', :one => "uno") To something like this: @siteItem = stub(''plmSiteItem'', {''one'' => ''uno'', ''two'' => ''dos''} ) So that I can do this:
2007 Aug 31
48
Deprecating the mocking framework?
I saw in one of Dave C.''s comments to a ticket that "our current plan is to deprecate the mocking framework." I hadn''t heard anything about that, but then again I haven''t paid super close attention to the list. Are we planning on dumping the mock framework in favor of using Mocha (or any other framework one might want to plug in?). Pat