similar to: SQL queries in Rails

Displaying 20 results from an estimated 100 matches similar to: "SQL queries in Rails"

2005 Dec 22
7
Ruby on Rails and lookup tables
Hi, I''m a newbie on both Ruby and Ruby on Rails, and I''m struggling with my first app. I have a table with a column called "employee_id" which is a foreing key associating it with the "employees" table. I have populated both tables. When I run "ruby script/generate scaffold <model name> <controller>" it generates a web page with all
2008 Feb 26
5
Rails 2.0.2 MySQL 'year' datatype missing from ActiveRecord?
Hi all, This is my first post to the forum, and I''ll point out right away that I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I''m wrong here, but is the ''year'' datatype missing from ActiveRecord in 2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a datatype, but when I try to run a migration that has
2008 Jan 01
7
in_vertical_groups_of
Hi all, Here''s another contribution for anyone interested. In Railscast episode 28, Ryan Bates showed us in_groups_of which allows you to group array members such as >> list = [1, 2, 3, 4, 5, 6, 7] => [1, 2, 3, 4, 5, 6, 7] >> list.in_groups_of(3) => [[1, 2, 3], [4, 5, 6], [7, nil, nil]] This allows you to iterate over the groups and, for example, display a list
2008 May 06
12
Why before_filter is not working?
I have been scratching my head on this one for most of the day. Hopefully someone can help explain why before_filter isn''t working for my codes. In my Application controller, I have this: before_filter :login_required, :except => [:newacct, :create_newacct, :passwd_reset ] def login_required unless session[:user_id] flash[:notice] = "Please log in"
2008 Sep 17
13
Capturing the sql from a statement without executing it?
Hi guys, Is there an elegant way to capture the sql that would have been executed by an ActiveRecord statement, without actually executing it? :) I''m imagining something like sql = User.find(1).groups.to_sql or perhaps sql = ActiveRecord::Base.capture_sql { User.find(1).groups } resulting in sql = ''SELECT * FROM groups INNER JOIN memberships.... WHERE users.id =
2008 Jun 10
7
ActionMailer undefined method `parameters' - Rails 2.1
Hello Rubyists, I''m currently trying to get email hooked up via ActionMailer, and while I''ve gotten it to work in the past on Rails 1.2.x, I''m seeing an error that I''m unfamiliar with. Right now, I''m just trying to send email from my dev box via the SMTP server at work. My development.rb file: #...snip config.action_mailer.delivery_method = :smtp
2008 Jul 01
8
Scaffolding: Create, Edit, Destroy in admin area
Hi Community, I''m currently trying to create a blog software in rails, but I''ve got a problem: I generated scaffolding for my articles and only want administrators to write, edit or delete articles. So I wanted to move this parts to another, secured controller. The one controller to display articles is called articles :), the other is also called articles, but is located in a
2007 Dec 28
11
LIKE clause in rails
Hello, I am trying to achieve a search functionality in the following manner i have an table called people which has first_name,last_name,etc... After the user form to search people is submitted i get the params hash as params[:persons]={"first_name"=> "%John%","last_name"=>"%Stevens%"} NOTE : I have changed the params hash to include the %. Now
2008 Apr 04
6
validates_numericality_of :not_equal_to
I have a situation in which I want to validate a number is not zero. Both positive and negative values are acceptable, just not zero. validates_numericality_of has an :equal_to attribute, but I don''t see a :not_equal_to. I have not yet been able to find anyone who has discussed this. I did find information about custom validators, so I am now using a custom validator to check the field
2007 Dec 24
5
output link_remote_to in helper
Hi all, I have a complex link_remote_to link I need to generate often. I want to DRY up my view and create a helper that generates this link_remote_to for me. Is there a way my helper can output the link_remote_to javascript? Thanks STijn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 Jan 07
1
Migrations and doubles?
I''m trying to start using migrations (I <3 migrations!) on a project that stores geocode data in the database. This is a pretty major problem because float is not precise enough to store this information. Are there plans to support double? What are my options here? Cheers, Jim -- Posted via http://www.ruby-forum.com/.
2006 Mar 26
1
add_primary_key Re: #3735
Hey guys, With the addition of has_many :through, a number of people will probably want to add primary keys to their current ''rich association'' tables. Currently we don''t have an add_primary_key. We have a ticket for it[1], and I''ve attached a simple patch[2]. It works fine for mysql and postgres (8) and Rick is looking at sqlite. Could those of you who use
2006 Jan 13
19
Problems with scaffold''s parameter on Oracle
Hi I run Ruby on Rails on Oracle XE. I have a simple table: create table customer(id number primary key, name varchar2(100)); And ruby script\generate model Customer ruby script\generate controller Customer http://localhost:3000/customer/ - show a fine list, but when I click show/edit/destroy, I get an ORA-01722: OCIError: ORA-01722: invalid number: select * from (select raw_sql_.*,
2008 Jul 28
1
Re: switching between projects?
pepa007 wrote: > Hi, > > sorry for newbie question: > > how do I switch between projects on command line? > > I know ''rails projectA'' creates projectA. but if I have another > projectB in another folder, how do I make this one active? > > Thank you By "active", I''m assuming you mean you want to see it in the web browser. When
2010 Jul 07
4
Haml ... ending a line with a | (vertical bar)
I don''t know if HAML questions are appropriate here ... but here goes. How does on end line to be rendered with a vertical bar (|) ? The vertical bar is a line continuation, aparently. Doing \| cause the vertical bar to be emitted ... as well as the backslash. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups
2007 Dec 09
5
Browserized Styles Plugin
Browserized Styles provides a dead simple way to create browser- specific CSS code for use in a Rails application. All you need to do is create a .css file targeted to a browser by appending an underscore and identifier to the end. === Installation === script/plugin install http://svn.intridea.com/svn/public/browserized_styles === Example === Let''s say I have some complex CSS code
2011 Apr 23
1
rake spec fails where rake spec:(models|controllers|views) pass
I''m still trying to work into Ruby 1.9.2 and am now experiencing something that makes no sense to me. Using rspec 1.3.2 and rspec-rails 1.3.4 with rails 2.3.11 on ruby 1.9.2-p180, when I $ rake spec:models they all pass. When I $ rake spec:controllers they all pass. When I $ rake spec:views they all pass. But when I $ rake spec I get <path to
2008 Sep 12
3
Help: A copy of ModelSecurity has been removed from the module tree but is still active!
Hi all, I''m posting this in the hope that someone who understands rails dependencies can shed some light. I''ve implemented a "ModelSecurity" module in the vein of Bruce Peren''s old ModelSecurity plugin (http://rubyforge.org/projects/model- security/). My ModelSecurity module lives in $RAILS_ROOT/lib. It is automatically included into ActiveRecord::Base by a
2007 Dec 27
17
2.0 & "Agile Web Dev..." book
Just running through the first little project (depot) in ''Agile Web Development with Rails''. It isn''t scaffolding like it says it should in the book. After running: >rails -d mysql depot then SQLing: drop table if exists products; create table products ( id int not null auto_increment, title varchar(100) not null, description text not null, image_url varchar(200)
2008 Sep 22
8
TimeZone daylight savings time problems
Here is the following from my console: >> Time.now => Mon Sep 22 11:33:34 +0200 2008 >> Time.now.utc_offset => 7200 >> TimeZone[Time.now.utc_offset] => #<TimeZone:0x11aea90 @tzinfo=nil, @utc_offset=7200, @name="Athens"> >> Time.now.in_time_zone(TimeZone[Time.now.utc_offset]) => Mon, 22 Sep 2008 12:34:22 EEST +03:00 (I am in Spain - CET - and