I've got a few classes in lib/ which are not reloadable (due to their internal structure, its a jruby application). How can I tell rails to not reload these after each and every request?
Thanks!
Hi! I am looking for method for parsing route path like this:
ActionController::Routing.new("post_path").parse
#=> {:controller => "posts", :action => "index"}
It should be opposite to url_for
Upd
I've found out:
http://stackoverflow.com/questions/2222522/what-is-the-opposite-of-url-for-in-rails-a-function-that-takes-a-path-and-genera
ActionController::Routing::Routes.recognize_path("/posts")
So now I need to convert posts_path into "/posts"
My text editor of choice for PHP work is Panic's Coda. But for Ruby on Rails, it's autocomplete feature is continuously in my way and ROR's standardization on 2 space tabs does not play well with Coda's settings. I've been going back to TextMate for ROR work, but was wondering if there were better options.
I'm using Rails 2.3.2 and using Paperclip to upload photos. I'm also using a slightly customized subdomain_accounts.rb to set some account-specific variables. My question is this:
How can I set the bucket used in Paperclip to be dependent on the current account? Since this looks to be a model attribute set up early on, how can I override it later? Thanks.
What's the best way to add foreign keys to my existing tables in Rails with an underlying MySQL database? clearly the solution should be done in a migration, as I want this versioned. Otherwise I'd create the constraints myself.
I can't seem to find one, conducive response to they above. Again, the tables have already been created with previous migrations. I'm just going back now and adding referential integrity wherever it's applicable.
Does anyone know if activemodel works with 2.3.5? I'm looking for this exact functionality (namely, validations for non-AR objects) and I'm trying to find a clean solution for a Rails 2.3.5 app.
Or if anyone knows of a good gem/plugin to use that can mimic activerecord like validations for non AR objects, I'm all ears
I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate.
I have created a new app from scratch with no options to verify.
Any idea why this is happening and how to fix it?
I am just beginning to build my Rails application and thus far I've followed a RESTful design and it's proven much easier to understand and organize the code and structure of the application. I have things like posts and comments. However for the front page. I want to display all the latest posts but also may be in the sidebar display things such as Latest Comments and Latest events. What's the best way to go about this while maintaining the RESTful philosophy?
Hi,
I'm running through the Ruby on Rails tutorial at http://guides.rubyonrails.org/getting_started.html (adjusting where appropriate for Google's App Engine). All is well up till section 6.3: when I try to click "New Post", I get the following error:
Internal Server Error (500)
Request Method: GET
Request URL: http://localhost:8080/500.html
access denied (java.io.FilePermission /dev/urandom read)
It works fine when I upload the application to Google's App Engine; it's just on my development machine (OS X 10.6) that it doesn't work.
Thanks in advance.
I just got started with rails, and when I testing in development mode, I see in the logs that my Mailer action is taking 1175ms. Is there anyway to find out what exactly is the slow step?
Also, there is a line that says (View:2, DB:1). I assume the DB means number of database lookups, but what about the view?
I have installed Ruby on Rails in Ubuntu 10.04:
$ sudo gem install rails
$ echo $PATH prints:
/home/koningbaard/.gem/ruby/1.8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
But when I run $ rails --version, BASH tells me that rails is not currenly installed, and that I can install it with apt-get, which I don't want (I want it installed through gem).
Can anyone help me where I can find it and how I can add it to my PATH? Thanks
I want to run a paperclip method on create only
has_attached_file :file
This method doesn't seem to accept the :on = :create that some other rails methods do.
I tried:
before_create
after_create
etc, but those didn't work.
I also did:
if :create
How can I test if the controller is using the create method from the model?
Thanks!
For some reason the code I have included below does not interpolate the variables into the template. It simply copies the file over verbatim. I cannot figure out why.
https://gist.github.com/60484f7b57b06b6eb3e3
The Rails version is 2.3.4.
Thanks in advance!
$rails --help
...
Options:
...
-m, [--template=TEMPLATE] # Path to an application template
#(can be a filesystem path or URL).
What does this option mean?
Hi
I'm wondering how to implement highlighting of changes to user edited articles on a wiki style rails project. Since articles may be fairly lengthy I'd ideally like strikethrough and highlighting, similar to github and wikipedia for example. Despite searching around the net I've not really come up with much, apart from instiki which is a complete wiki application.
Thanks in advance for any advice.
I have a string like this:
"foo=bar&bar=foo&hello=hi"
Does Ruby on Rails provide methods to parse this as if it is a querystring, so I get a hash like this:
{
:foo => "bar",
:bar => "foo",
:hello => "hi"
}
Or must I write it myself?
EDIT
Please note that the string above is not a real querystring from a URL, but rather a string stored in a cookie from Facebook Connect.
I have a simple Ruby on Rails form which includes an authenticity_token. Unfortunatly, I missed that when you page cache this page then the Authenticity Token becomes invalid. I'm glad I figured it out however.
How do you solve caching in such a case?
Is there any way in a Rails STI situation to through an error when the base class is Instantiated? Overriding initialize will do it but then that gets trickled down to the subclasses.
Thanks
In Ruby on Rails, routes.rb, if we create a "named route"
map.something ":a/:b", :controller => 'foobar'
it will also create something_path and something_url which are two methods usable in the controller and in the view. Does map.connect create something like that too? Otherwise, isn't map.connect somewhat disadvantaged in this way? I checked that connect_path and connect_url both aren't created automatically.
Hi,
I'm trying to redirect from one controller to another in Rails and I am getting this error:
undefined method `call' for nil:NilClass
The code is pretty simple (in def create method):
@blog_post_comment = BlogPostComment.new(params[:blog_post_comment])
respond_to do |format|
if @blog_post_comment.save
flash[:notice] = 'Comment was successfully created.'
redirect_to(@blog_post_comment.blog_post)
else
render :action => "new"
end
end
Save goes ok, the value gets into the database. How can I work around the redirect fail?
So I have an engine which defines some models and controllers. I want to be able to extend functionality of some models/controllers in my application (eg. adding methods) without loosing the original model/controller functionality from engine. Everywhere I read that you simply need to define controller with the same name in your application and Rails will automatically merge them, however it doesn't work for me and controller in engine is simply ignored (I don't think it's even loaded).
Hello I want to create seo optimize url in rails.Same like done in stackoverflow.
Right now this is my url
http://localhost:3000/questions/56
I want to make it something like this:-
http://localhost:3000/questions/56/this-is-my-optimized-url
i am using restful approach.
is there any plug-in available for this.
I have been writing specs for controllers and models, but I have never written a helper spec. I have no idea where I start.
I have the following snippet in application_helper.rb
def title(page_title)
content_for(:title) { page_title }
end
How should I write a helper spec on the code?
Also if there's any open-source Rails app to show good helper testing/specing, do let me know.
What the best way to store CSPC and UPC codes are in Rails? I used integers with SQLite, but had overflow issues when moving to production. I've since switch to strings, but am not sure if a better generic datatype (needs to support SQLite, MySQL and PostgreSQL).
Thanks.