Displaying 20 results from an estimated 1000 matches similar to: "How to find the last SQL statement executed in ActiveRecord"
2006 Apr 12
6
distinguishing mapped urls from ordinary action urls
I want to present different view depending on the url.
example below:
http://myapp/start/show?url=xZq
http://myapp/xZq
both addresses are controlled by a single controller and the same action.
the second url is only mapped in routes.rb
how can I distinguished the mapped url and present a slightly different view
in it?
Sabon
-------------- next part --------------
An HTML attachment was
2006 Mar 24
4
validate if different?
Hi, I seem to remember seeing the equivalent of saving only if all
attributes are different. I can''t seem to find that now in the API or the
agile book.
I''m using the acts_as_versioned and only want to save if the input is
different.
Thanks,
Steve
http://www.smarkets.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Mar 18
9
How do I write this SQL the Rails way?
I''m trying to find all the unique bill_number, status records in Bills
table. I can do it with a find_by_sql statement like this:
@records = Bill.find_by_sql( "select distinct bill_number, status
from bills
group by bill_number, status;")
How would I rewrite it using ''find :all
2006 Feb 15
12
Does your *shared* hosting account work without errors?
Does your *shared* hosting account work without errors?
I''m interested in both positive and negative reports. If you are willing,
please contribute
- name of the hosting service
- how long you have used them
- your experience ("flawless!", "it''s crap!")
You *do not* need to reply saying your VPS service works great. This is
about *shared* hosting
2006 Mar 24
6
login forms , redirect_to and ajax-scaffold problems
Hi,
I have a standard type authentication technique direct from AWDWR, so there is a
before_filter :authorize_employee, :except => :login in my employees_controller.rb
the authorize_employee is in application.rb
def authorize_employee
unless session[:employee_id]
flash[:notice] = "Please log in"
# save the URL the user requested so we can hop
2006 Mar 18
16
fixrbconfig - does it work on intel macs?
I''m trying now to do "sudo fixrbconfig" in the terminal, and I get this:
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h does not exist. This
probably means you haven''t yet installed Xcode from the Tiger DVD. You
won''t be able to compile Ruby extensions without it. Please install it
then rerun this program.
I''m on an intel mac. Am I unable to use
2006 Mar 22
3
Something wrong with content_columns
I have a database with a couple of tables. One table called spares has
foreign keys in another called equipment. When I create a new record,
it is added to the spares table however the list action does not show
all the columns in the table. It only shows those columns that are not
foreign keys. I am using the default action generated by scaffold for
list.
Why is that so? Do i need to re-write my
2006 Feb 16
2
simple association question
I have two models, Donor and Contribution, and have has_many and
belongs_to set respectively.
My question is regarding creation of associated objects. I''ll let the
code speak:
me = Donor.find(1)
contribution = me.contributions.create do |e|
e.amount = 164.00
e.category = Category.find(1)
end
I thought this was valid, but it doesn''t work properly - it appears to
2006 Mar 18
5
How would I get the previous id from the database?
I''m trying to get the id of the previous row prior to what would be
input and then rename an uploaded image to that row number.
So say the previous row was 19 and the image in that row was named
19.jpg, I''m wanting to name the next uploaded image as 20.jpg since the
row that would be added then would be 20.
Right now I''ve just got:
@new_tutorial =
2006 Apr 12
1
acts_as_list problem with records coming in and out
I have the model that acts as list
acts_as_list :scope => ''featured=1''
As you can see, I only need to order the records that are featured. However,
from time to time I switch some featured items off and mark others as
featured. When this is done, I start getting dublicate numbers on the list
and ordering starts getting problem...
What would be the good approach to
2006 Mar 16
3
ACLSystem and session variables
I am using the ACL System that is described on the Rails wiki and I have
a quick question. I want to set the "role" as a session variable so
that I can display certain navigation schemes and I was doing it like
this:
@session[:user][:role] = @user.roles
When I print out this variable I get:
#<Role:0x3262d80>
How can I turn this into a readable value? I tried .to_i
2006 Apr 21
4
link_to_function with submit
I looked everywhere but couldn''t find it.
I don''t want a submit_tag or image_submit_tag but a normal link that
submits my form.
Normally I would do this with a javascript like
function sendForm ()
{
document.forms[0].submit();
}
but this doesn''t work with form_remote_tag
link_to_function( ''Send'' , "sendform();")
So the question is:
2006 Jul 14
18
ActiveRecord Love While We''re At It
I am working on and will be publicly showing ActiveRecord some love
around the time of the RubyConf*MI [1] in late August.
My main focus is getting AR to better handle inserts, updates and merges
when working large sets of data. It can improve improve performance by
400% to 600% in preliminary benchmarks.
I am coding this in a way so it can be patched to AR easily, and with
that in mind
2006 Mar 18
3
Weird stylesheet_link_tag issue after moving servers
Dear experts,
I am in the process of switching servers for my application.
Before the move everything was working properly.
After the move
<%= stylesheet_link_tag ''/stylesheets/styles.css'' %>
generates
<link href="//stylesheets/styles.css" media="screen" rel="Stylesheet" type="text/css" />
2006 Mar 24
6
Microsoft SQL Server has me stumped
I''m tinkering around with an old legacy table in SQL Server 2000.
Ruby 1.8.4, most recent ADO.rb file from RubyForge, Rails 1.0
Here''s the model:
class InventoryItem < ActiveRecord::Base
set_table_name "[_SMDBA_].[_INVENTOR_]"
set_primary_key "sequence"
end
Everything works fine. I can retrieve records without issue.
However, when create a new
2006 Feb 16
1
validations with associated object
Does anyone know if Rails is supposed to validate associated objects on
creation?
Say you have a User model, with has_many posts, and a Post model which
belongs_to user. Further, the Post model has a validates_uniqueness_of
:title.
u = User.find(1)
# this should pass
u.posts.create :title => ''my new post title''
# this should fail
u.posts.create :title => ''my
2006 Mar 22
2
How to bypass routing for a particular request?
I would like to set up some my app. to display a standalone HTML page -
not rendered through RoR per se.
Something like
render(:inline => some_Javascript_function...
then in the Javascript
some_Javascript_function,
I want to open up a popup with the URL I specify. However, because it
is a relative URL, it is going through the RoR routing algorithm. I
don''t want that - can I
2006 Mar 27
13
Is this a bug in Ajax handling?
When a controller responds to a link_to_remote with a redirect_to, the
link_to_remote gets a success callback, this would seem like a bug to
me, at a minimum it should return a failure?
This is driving me crazy because all the login engines/generators
respond to an authentication error with a redirect_to. The work around
is to change them to all do a
render :layout => false, :status => 500
2006 Mar 18
2
basic operations in rails
Hi all,
This must be such a beginner''s problem, but I can''t figure it out.
I''m pulling two integers out of a database, and i want to divide one
value with the other, but i keep getting an error about operating on
strings.
Here''s the code -
low_freq = unsorted.last.freq
high_freq = unsorted.first.freq
divider = high_freq / low_freq
In my view, if i display
2006 Mar 25
2
Current controller
Hello railists,
I have a list of news headers on my index page. I would like to hide
this list if current controller is ''news''.
I put to main/index.rhtml
"<% unless @controller == "news" %> list here news headers <% end %>
. This doesn''t work.
So, the question is how to get current controller name in template ?
Thank You!
--
Posted via