I have an method in ApplicationHelper
def javascript_auto_link_tags
js_path = "#{RAILS_ROOT}/public/javascripts"
js = "#{controller.controller_path}.js"
javascript_include_tag(js) if FileTest.exist?("#{js_path}/#{js}")
end
This should find a javascript file based on the current controller file name and path so controllers/admin/...
OK, here's my problem, let me try to make it all make sense...
I've created a rails website for client X. I now have a client, Y, who wants a website that does the exact same thing as client X, but with a different skin.
Rails was perfect for this since all the skinning was in it's own folder and set apart from all the business logic. ...
How do you handle file upload in rail without attaching them to active record ?
I just want to write the files to the disk.
Thanks,
...
I am doing some controller testing with RSpec and Mocha. Here is an example
describe MenuItemsController, "creating a new menu item" do
integrate_views
fixtures :menu_items
it "should redirect to index with a notice on successful save" do
MenuItem.any_instance.stubs(:valid?).returns(true)
post 'create'
assigns[:menu_i...
I am using TestUnit and would like to determine if a function is called. I have a method in a class called Person which I set to be called 'before_update':
def geocode_if_location_info_changed
if location_info_changed?
spawn do
res = geocode
end
end
end
Then I have a unit test:
def test_geocode_if_locat...
I have this ruby function in a controller
def updateSession value
case value
when 1,2
session[:value]=1
when 3,4
session[:value]=2
end
end
And I have different links that redirect to different pages.
I would like to change the session value when clicking on those links by calling the updateSession function
Is it...
I just upgraded to Mac OSX Snow Leopard, and recompiled mysql (5.1.39) with the Snow Leopard XCode. I also reinstalled the latest mysql gem.
Now, when running
rake db:migrate
in a rails app, I get
dyld: NSLinkModule() error
dyld: Library not loaded: /usr/local/mysql/lib/libmysqlclient.15.dylib
Referenced from: /usr/local/lib/ruby/...
I have a method I want to call using AJAX in rails but I have no idea how to do so. The method is private and has no view. Right now all it SHOULD do is replace a div tags html to show a flash[:notice].
...
Hello,
I'm trying to set blog postings to publish at certain dates in the future. I have in my Posting model:
named_scope :published, :conditions => ["publish_at <= ?", Time.now]
I'm using this in my controller to call the published postings:
@postings = Posting.published
The development server works fine, but I believe the pro...
I was working on my website when I cam across this problem, I have 100 posts in my blog and I am paginating them 10 at a time, I display the 1st 15 and display a link at the bottom which basically is implemented using the link_to_remote tag.
<%= link_to_remote "More Posts", :url => {:action => 'view' ,:id => link.to_i + 1} , :html => {:...
I have a div tag that I want to change only if a function returns true, otherwise I want it to keep the same content. I used render: nothing => true but that removes everything.
<%= javascript_include_tag :defaults %>
<div id="x">Hi</div>
<% form_remote_tag :url => {:action => 'get'},
:update => 'x' do %>
<%= text_field_tag 'url' %...
My question is very similar to http://stackoverflow.com/questions/695971/java-http-post-to-create-new-product-in-a-ruby-on-rails-application
I have a form that I want to "post" to a form that looks like this
Offer:<br />
<input id="ride_togive" name="ride[togive]" size="30" type="text" />
</p>
<p>
Request for Offer:<br />
<input i...
I get the following error when I run my task via DelayedJob:
closed stream
/usr/lib/ruby/1.8/drb/drb.rb:961:in `select'
/usr/lib/ruby/1.8/drb/drb.rb:961:in `alive?'
/usr/lib/ruby/1.8/drb/drb.rb:1211:in `alive?'
/usr/lib/ruby/1.8/drb/drb.rb:1168:in `open'
/usr/lib/ruby/1.8/drb/drb.rb:1166:in `each'
/usr/lib/ruby/1.8/drb/drb.rb:1166:in `o...
I have a fresh install of Ubuntu Karmic, Ruby and Rails. I checkout out a working (production) application. Created the databases and ran the rake tasks. Made sure I had all the required gems of which acts_as_ferret by Jens Krämer was one of them.
Everything appears to be installed correctly.
The gems are listed in environment.rb inclu...
I want to define alternative sets of fixtures per database table.
For example,
class BusinessSpec
describe "some aspect of businesses" do
fixtures :fixture_set_1
...
end
describe "some unrelated aspect of businesses" do
fixtures :fixture_set_2
...
end
end
Is this, or something similar, possible?
...
When you do Something.find(array_of_ids) in Rails, the order of the resulting array does not depend on the order of array_of_ids.
Is there any way to do the find and preserve the order?
ATM I manually sort the records based on order of IDs, but that is kind of lame.
UPD: if it's possible to specify the order using the :order param an...
What is your favorite Rails admin tool and why? By admin tool I'm referring to those that let some users add records for all the tables, like the tool shipped with Django.
This question is subjective and I believe the matter is subjective, but I think it would still be nice to be able to read other people opinions and gather data on the...
What is the proper way to prevent client-side caching of a file when using send_file in rails?
...
Hi,
I'm looking for a good way to implement real time feed for my users on a Rails app (Phusion passenger server). Each feed can be different depending on the user and I expect to have one new item every 20 - 60s. Periodic ajax request doesn't look like the best way to do it for me.
I heard about Comet and I thought about having someth...
Hi all,
I'm working on a university project and my teacher set up the server for it, but after installing Ruby 1.9.x we had to return to Ruby 1.8.x, because of the Ruby 1.9/Rails 2.3.4 problem.
Now, every time I build a Rails app, it's always using Rails 2.2.3 gems.
I've changed the environment.rb (RAILS_GEM_VERSION = '2.3.4' ...), bu...