Displaying 20 results from an estimated 1000 matches similar to: "basic operations in rails"
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 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 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 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
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 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 20
5
How to find the last SQL statement executed in ActiveRecord
Is there a method for retrieving the last SQL statement executed by
ActiveRecord? I realize I can open the log file, but I''m looking for a
programmatic way.
--
Posted via http://www.ruby-forum.com/.
2019 Jan 05
1
unsorted - suggestion for performance improvement and ALTREP support for POSIXct
I believe the performance of isUnsorted() in sort.c could be improved by
calling REAL() once (outside of the for loop), rather than calling it twice
inside the loop. As an aside, it is implemented in the faster way in
doSort() (sort.c line 401). The example below shows the performance
improvement for a vectors of double of moving REAL() outside the for loop.
# example as implemented in
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 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
2012 May 23
2
Expected behaviour of is.unsorted?
Hi,
I've read ?is.unsorted and searched. Have found a few items but nothing
close, yet. Is the following expected?
> is.unsorted(data.frame(1:2))
[1] FALSE
> is.unsorted(data.frame(2:1))
[1] FALSE
> is.unsorted(data.frame(1:2,3:4))
[1] TRUE
> is.unsorted(data.frame(2:1,4:3))
[1] TRUE
IIUC, is.unsorted is intended for atomic vectors only (description of x in
?is.unsorted). Indeed
2013 Apr 24
1
multiple issues with is.unsorted()
Hi,
In the man page for is.unsorted():
Value:
A length-one logical value. All objects of length 0 or 1 are
sorted: the result will be ?NA? for objects of length 2 or more
except for atomic vectors and objects with a class (where the ?>=?
or ?>? method is used to compare ?x[i]? with ?x[i-1]? for ?i? in
?2:length(x)?).
This contains many incorrect
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" />
2008 Apr 17
1
Couldn't (and shouldn't) is.unsorted() be faster?
Hi,
Couldn't is.unsorted() bail out immediately here (after comparing
the first 2 elements):
> x <- 20000000:1
> system.time(is.unsorted(x), gcFirst=TRUE)
user system elapsed
0.084 0.040 0.124
> x <- 200000000:1
> system.time(is.unsorted(x), gcFirst=TRUE)
user system elapsed
0.772 0.440 1.214
Thanks!
H.
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 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:
2014 Jan 03
1
wishlist: decreasing argument to is.unsorted
I've just realized that it could be handy
to have a 'decreasing' argument in 'is.unsorted'.
And I'm cheekily hoping someone else will
implement it.
It is easy enough to work around (with 'rev'),
but would be less hassle with an argument.
The case I have in mind uses 'is.unsorted' in
'stopifnot'.
Pat
--
Patrick Burns
pburns at pburns.seanet.com
2007 Nov 08
2
question on image() function?
Dear friends,
My dataset is like the following:
x y mcpvalue
0.4603578 0.6247629 1.001
0.4603715 0.6247788 1.001
0.4603852 0.6247948 1.001
0.4110561 0.5664841 0.995
The x and y variables are unsorted.
I use the function image(x,y,mcpvalue) to generate a plot, but the error
is that "increasing 'x' and
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 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