Displaying 20 results from an estimated 1000 matches similar to: "Reinstantiate controller during functional testing"
2009 Sep 28
6
What is the most efficient way to split a table into 2 groups?
I have the following:
@lot = Lot.find(params[:id])
part_nums = Part.all(:conditions => ["id <> ?", @lot.part.id])
I guess I should mention that
Lot :belongs_to => :part
I was looking at the log following the execution of these two
statements and I saw something like this:
Lot Load (0.4ms) SELECT * FROM "lots" WHERE ("lots"."id" = 13)
Part
2009 Dec 10
2
How to customize the default scaffold?
I know the scaffold generator is really only useful for beginners
and/or very the preliminary state of a project, but I find that I use
it a lot (especially, since I am still a beginner). There are a
couple of things I find myself tweaking (or wanting to tweak, but
never getting around to tweaking) each time I generate a new scaffold:
1) Change the layout from blah.html.erb to
2008 Dec 13
2
What is "The Rails Way" to do this?
I have a PHP application with the following in one of the "views":
<input type="button" onClick="newAlt()" value=" + "></nobr>
The JavaScript for "newAlt()" is:
// using DOM create new input box for alternate part
function newAlt() {
var html = "<input style=''background-color:#FFFFCC'' ";
html +=
2008 Dec 13
2
how to import a dump .sql file in a rake task
I have a dump of some tables to be filled when the app is setup
''.../db/dataset/regions_dpt_cities_codes.sql''
I would like to execute a task similar to the >mysql source
<dump_file>
like :
ActiveRecord::Base.connection.execute("source #{path};") (which
doesn''t run fine, of course....
is it possible in a rake task ? if yes, any suggestion ?
2008 Dec 23
2
NoMethodError in Book#show_subjects
Hi,
I am quite new to ROR.I am trying to create a rails simple application
that has informations about Books and Subjects.Srangely, I finished
creating a basic application, and it worked fine.
But then , I just tried to add some more values in the database, and
faced problem with migration, that just made me crazy. SO I deleted the
database and did the database and migration thing all over again
2008 Dec 25
5
One question about Dynamic Select Menus
Hi all,
Merry X''mas first :-)
I have "Product","Category","Subcategory" 3 Model, and when new
"Product", I want to use "Dynamic Select Menus" just like Ryan
mentioned in http://railscasts.com/episodes/88-dynamic-select-menus
I have everything down. But when I visit the js file, I got following
error
Showing
2005 Dec 15
2
link_to_remote and browser compatibility
link_to_remote generates the javascript: new Ajax.Updater(...). Have I
missed something or doesn''t this handle browsers with javascript support
but without XHR support?
What I''d like to do is:
1. If the browser supports XHR, use XHR
2. If the browser supports javascript (and perhaps even if the XHR
request fails) do a POST via javascript
3. If the browser doesn''t
2006 Mar 22
3
Parent-Child Tables Help
can someone help me with this
i have a table
cars
(
id int
model_id int
make_id int
color_id int
description text
constraint fk_cars_carmake foreign key(make_id) references
carmakes(id),
constraint fk_cars_carmodel foreign key(model_id) references
carmodels(id),
constraint fk_cars_color foreign key(color_id) references colors(id)
)
carmakes
(
id int
carmake varchar
)
carmodels
(
id
2007 Apr 26
2
assert_select with respond_to JS or xhr?
Hi everyone,
I am a bit confused with xhr? and respond_to.
I have the folloing code in my view to update the ''emails'' ID
link_to_remote(image_tag("refresh"), :update => "emails",
:url => { :action => "list_emails" })
in the controller side i have somthing like :
[..]
respond_to do |type|
type.html { render :action
2006 Jun 24
5
request.xhr? vs. respond_to
Searched around this forum, but didn''t find an answer for this question.
Can you help this newbie understand any overlap and/or difference
between request.xhr? and respond_to?
If request.xhr? is true, should I expect it wants.js below?
respond_to do |wants|
wants.html { redirect_to(person_list_url) }
wants.js
wants.xml { render :xml => @person.to_xml(:include
2007 Jun 27
2
Controller specs not shareable?
Hi
I just wondered if there was a reason why Rails controller specs are
not shareable? eg
describe "All XHR POSTs to /gap/calculate_quote", :shared => true do
controller_name :gap
# ...
end
describe "XHR POST /gap/calculate_quote with valid details" do
it_should_behave_like "All XHR POSTs to /gap/calculate_quote"
# ...
end
blows up with
2006 Jul 12
3
request.xhr? is false after redirecting an AJAX request?
Dear everybody
I''m trying to develop a web application that makes use of AJAX, but also works
if a user has no (or doesn''t want to use) JS. For normal requests, this is
pretty easy. Almost every action ends with
render blahblah, :layout => !request.xhr?
This way, I can use the same action to render a full page (with layout) as
well as rendering an AJAX request (only the
2008 Mar 31
1
How to make a ajax (xhr) redirect?
Hi all,
In my application, I want seamless degradability so I use request.xhr?
to check whether a request is an ajax call. However here and there, I
need to use redirect_to - in this case the request is not xhr anymore,
and the check doesn''t work as expected. Is there a way to make xhr-
like redirect (which allow to get to another controller+action)?
Thanks,
- Chuong
2009 Oct 16
5
Rails 2.3 Model.touch(:column) always also updates :updated_at???
Hi,
Am I the only one (i.e. something I do is wrong), or does the touch-
method always update updated_at, even though giving it a column to use
INSTEAD is meant to update just that column???
Thanks,
Michael
2007 Dec 03
8
automatic 'verify :xhr => true' for methods ending with _xhr
hey guys,
i am writing a couple of actions which are only used with an xhr. I
''protect'' them all against a direct access with the ''verify'' method in
the controller
verify :only => ..., :xhr => true
it would be cool if the system would automatically recognize the xhr
actions and protect them ... i want to postfix methods with ''_xhr'' and
2008 Mar 24
8
Proper idom for link_to_if
What I wish to do is to have a construct like this in a view:
<%= link_to_if <some test>, "New Model View", new_model_path -%>
<some test> has to return true if new_model_path is defined and false
otherwise. What is the proper idiom to do this in rails 2?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received
2006 Jul 06
1
multiple xhr requests
Hi I have a window that looks like this
--------------------
| | Enter
--------------------
That box will take a command that the user enters and runs it on a
server in the background loading a new window for the user to view the
results. Is there a way to take multiple xhr requests so that the next
request the user enters , a new window will pop up right away, instead
of
2008 Jun 05
2
xhr :post giving wrong number of arguments on rails 2.1?
Getting a strange error.
In a story I have the following step:
When "I submit a search name" do
xhr :post, ''/searches'', {:search => {:given_name => "bob", :family_name =>
"smith"}}
end
I am getting:
ArgumentError: wrong number of arguments (4 for 3)
stories/searching_story_spec.rb:45 in "I submit a search name"
But I only
2010 Sep 21
7
Ajax CSRF in Rails3
I''m using rails3. It does not seem to check the authenticity_token
when doing a POST using Ajax. I traced this to:
module ActionDispatch
class Request < Rack::Request
.....
def forgery_whitelisted?
get? || xhr? || content_mime_type.nil? || !
content_mime_type.verify_request?
end
end
so you don''t check if its a get? or a xhr? (ie ajax request). Is this
correct?
--
2006 Jul 26
4
How to Firebug XHR/AJAX requests
Saw a lot of recommendations for Firebug
(http://www.joehewitt.com/software/firebug/) on this list. I''ve scanned
its docs and tried it--many useful features. But I''m so dense that I
can''t get it to spy XHR/AJAX requests and their response on FC5 running
Firefox 1.5.0.4 and Firebug 0.4.
Can someone tell me how to get to