similar to: Rspec and plugins

Displaying 20 results from an estimated 100 matches similar to: "Rspec and plugins"

2009 Aug 19
2
Create! Syntax
Hey All, Two questions. Firstly, what is the difference between create and create! I see that create is document in the api http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002269 What is the difference between the two of these functions and where is the create! function defined. Also, What are the differences between these two calls? a) SomeModel.create!{ :property_a =>
2006 Jan 11
2
How to execute an SQL statement in rails?
Hello, This is probably a silly question but looking at "api.rubyonrails.org", I can''t seem to figure out which method I should be using ... I want to execute an sql statement, like "truncate table BLAH" from within one of my rails app ... What''s the "right" way to do this? Thanks, /B -- Bruno Mattarollo <bruno.mattarollo@gmail.com>
2006 Jul 05
10
Scalable alternative to #find_all
Is there any scalable alternative to iterating all the records of a certain model? #find_all seems to load everything into memory. With 500.000 records it will be a swap storm. Pedro.
2006 Feb 07
4
Ruby, Rails & Inheritance
Hi! I am looking for a solution for the following problem: Some of my models share some attributes and also was in need for some extra features, so I created a class "RecordWithFeatures": ----------------------------------------------------------------- class RecordWithFeatures < ActiveRecord::Base # @Override def self.descends_from_active_record? superclass ==
2006 Jul 12
1
When to use Mutex::synchronize?
I have a simple question when to the synchronize method in the Mutex class. Now that backgroundrb has allow_concurrency = true there is no need to synchronize database calls in threads. The question I have is lets say I have a simple method in my worker as follows: def some_method SomeModel.find_all each do |obj| obj.some_count += 1 obj.save! end end It accesses the database, but
2006 Jun 26
1
Separate Read and Write Database
Hello, I need to access an mirrored database with one read and one write cluster. Is there a way to tell a model to use two connections? So that all updates etc go to the write database and all read from the read one? This is a fixed set up I can not use MySQL 5.x stuff and additionally i get a token on write, which can be checked on read (and wait for replication) if new data is needed. I
2006 Feb 16
10
Ruby class variables and access from view templates
I have an app that requires me to define a class variable (actually an array) in a controller and then access it from within a view. It seems that the class variables aren''t working right. Here is an example of what I''m trying to do. class DisplayController < ApplicationController @@thumbnail_array = Array.new ... def some_method @@thumbnail_array = SomeModel.find_all
2006 Feb 08
3
Extends ActiveRecord from the application ?
Hello, I just want to create a method that will be available for all models. Is it possible ?
2006 Apr 07
3
List of all Models
Anyone know a pretty way to get a list of all Models? That is, a list of all classes which inherit from ActiveRecord:Base I can''t seem to figure it out! The best I''ve got is to list the /app/models directory... but, that is *dirty*. -hampton. -------------- next part -------------- An HTML attachment was scrubbed... URL:
2006 May 08
4
rake db:migrate
Would it make sense for rake db:migrate to support creating databases if it is not found, with blessing from user to prevent typos, or as an additional command line switch. Or am I just being too lazy? -- Posted via http://www.ruby-forum.com/.
2006 Nov 17
4
before_destroy and sessions
(Semi-newbie.) I want to ensure a user''s able to destroy only his own objects. I''ve set session info at login: session[:user_id] = user.id Now I try this in the model of my deletable objects: before_destroy :destroy_your_own def destroy_your_own raise "Can''t delete that!" unless session[:user_id] == self.user.id end which snags EVERY attempted
2007 Nov 07
7
Help on loop
Hey, I have got a script that returns a long list of font family names, which I all want to store in a variable (array). I tried doing this with @f = font.family also in the for loop below but it only prints the last item when I want to display the results. require ''rubygems'' require ''RMagick'' include Magick for font in Magick.fonts puts font.family end
2012 Sep 11
3
question about how to set up an active record adapter to prefer use of prepared statements...
Hi, I am writing an active record adapter for our new database and when I run the tests I see lots of statements that could be run as prepared statements, but instead of passing me bindings AR passes me a fully specialized SQL string, not in all cases, but in many. Here is an example: SELECT addrs.* FROM addrs WHERE addrs.user_id = 153 FETCH FIRST 1 ROWS ONLY I do have this hook set up:
2005 Dec 31
7
Dynamic form? Not really!
Hi guru''s out there, Im happilly coding my first rails app, and all goes well. I find myself manually coding in a particular field all the time (company_id), that relates the contact to a company. The total coding of this form seems somewhat much. Could somebody tell me what Rails power I''m possibly missing and stuborn as I am trying to do myself? I was wondering if the
2006 Feb 15
2
extending rails via /lib - problems
I wanted to group some functions which I use in some models in one place. Controllers have application.rb and views have helpers but I couldn''t find anything about models. Using the /lib directory seemed to be the only way. Alright... so I have something like this: /lib/code.rb class ActiveRecord::Base def method_a(n) ....... end def method_b(n) ........ end end
2006 May 05
7
vim: space or tab in indenting?
this is semi-off topic but still related to ror. i had a problem with testing my depot program (which i follow the tutorial in agile web development book). it took me many hours to solved the problem. all the while i thought i was using spaces inside the test/fixtures/products.yml programmer_book: id: 1 title: Pragmatic Programmer description: Best book
2006 Apr 14
5
One Controller, Many models
Hello all, I am working on a app right now that is going to replace a paper form process out client has. This process has quite a few forms (about 30) and different groups of forms (section) need to be filled out based on what information is required from the user. For example, here is a possible process of 2 users: user 1 user 2 Section 1 Section 1 Section 2 Section 2
2008 Jul 02
2
How to write the method before_destroy and the test
How to write the method before_destroy? Here is my code: def before_destroy errors.add(:isdefault,"Can''t destroy default record") if self.isdefault return false end or I should write it like below? def before_destroy raise(Can''t destroy default record") if self.isdefault end and how to write the test for it -- Posted via
2005 Nov 25
4
Set default order for find(:all) in a model
Hi everyone Is there a way that I can get the find(:all) method to return in a specified order, without including the :order argument every time? Guess I just don''t like typing... Cheers _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
2011 Sep 05
8
In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL
Hello! Just upgraded to Rails 3.1, ran my test and found this issue: class Trade < ActiveRecord::Base has_many :transaction_trades ..... def Trade.do_something stale_trades = Trade.count(''transaction_trades.id'', :include => :transaction_trades, :group => ''trades.id'')