I know named_scope has been changed to scope in rails 3.
How do I perform default_scope in rails 3, I've had a good google but found nothing for defaults scopes.
In Rails, is there a way to display different error messages on a production rails server (a nice graphic) vs a development server (detailed error information, stack trace, etc.)?
I would like to find some help building a tree interface in Rails. I've tried using jsTree but am having trouble integrating it properly into Rails.
Thanks.
Its not the another language debate, its a decision making discussion.
I am a ASP.NET developer, but want to learn other frameworks/language (open source). I don't know from where i should start and why? Django and Rails both seems promising, but i am confused which one i should choose to start, or i should choose some other framework. I know learning the language (python or ruby) is must before start Django or Rails.
Please advise.
Hi guys,
I'm developing JAX-RS application and it's working fine. Now, i want to develop web service client application using Rails. And my question is which is the best way to parsing RESTfull webservice's response in Rails?
I've noticed that the Rails log correctly displays the time taken to execute an action in the logs, and that the View: part of that is also rendered correctly. However, the DB: value is always zero:
Aug 11 13:00:22 [2326] INFO: Completed in 2072ms (View: 94, DB: 0) | 200 OK
In fact, all my DB timings are being logged as zero. I'm logging at DEBUG level, in development mode, running Rails 2.3.2.
Apologies in advance if the answer is blatantly obvious.
What happened to asset_host in rails 3?
Earlier I can put following code into development.rb and get all assets not present on development:
ActionController::Base.asset_host = proc do |source, request|
unless File.exist?(File.join(RAILS_ROOT, 'public', source.sub(/\?\d+$/, '')))
'http://example.com'
end
end
But in rails 3 there is no such method and google does not help me.
I have a rails application that allows searches using longitude and latitude. I have added a 'pretty' route with:
map.connect 'stores/near/:longitude/:latitude', :controller => 'stores', :action => 'index'
This works for integer latitude and longitude values (http://localhost:3000/stores/near/-88/49) but fails for decimal values (http://localhost:3000/stores/near/-88.341/49.123) giving:
Routing Error
No route matches "/stores/near/-88/49.0" with {:method=>:get}
Any ideas how to use pretty URLs in rails with decimals?
In a blog in Rails I want to have paths like
http://mydomain.com/posts/28383/comments#21
This is the 21st comment of the 28383th post. The 21 is not an unique id, but the pair 28383, #21 is unique.
How can I do this in Rails? Do I have to change the routes? the model?
I will be very thankful if you can point me in the right direction
Thanks
Ruby on Rails is maybe the most praised web development framework exist. There are tons of reasons for that, but every framework, even the best of its kind, has its drawbacks.
I'd like to know the most common problems you run into when developing Ruby on Rails applications and the issues you often struggle with.
I wrote my first Rails 3 app and it ran absolutely fine in development mode. Now I deployed it on my server and wanted to start it in production mode. The app starts but none of my images or stylesheets are being loaded. The Rails console outputs a lot of RoutingErrors to those files. Isn't that mode available yet?
hi all,
I am trying to install ruby on rails in my own intranet, I don't have an internet connection. There are several tutorials out there that try to explain how to do so, but they don't seem to work. Does anyone know of a full installation (including ruby, rails, IDE) that doesn't demand downloading files from the internet?
Thanks alot!
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).
I have an Rails application with SayController, hello action and view template say/hello.html.erb. When I add some cyrillic character like "?", I get an error:
ArgumentError in SayController#hello
invalid byte sequence in UTF-8
Headers:
{"Cache-Control"=>"no-cache",
"X-Runtime"=>"11",
"Content-Type"=>"text/html; charset=utf-8"}
I use Windows 7 x64, Ruby 1.9.1p378, Rails 2.3.5, WEBrick server.
Is there any way to to setup Rails generating files with tabs instead spaces?
Or maybe is there any way to auto replacing spaces to tabs in gedit?
Cause I really prefered tabs and it's really take some time to replace spaces to tabs in new generated files by Rails.
Thanks in advance!
Hello, I'm looking for any pointers on how to write a rails web app without ActiveRecord.
A doc or an example of a (not too complex) web app using storage backends other than a relational database would be greatly appreciated.
It's not clear on what should be implemented in the model classes in order to make the rails app work without the ActiveRecord layer.
Thanks,
In Rails 2 we can add custom new actions to resourceful routes, like:
map.resources :users, :new => {:apply => :get}
How do we achieve the same thing in Rails 3?
resources :users do
get :apply, :on => :new # does not work
new do
get :apply # also does not work
end
end
Any ideas?
The config/environment.rb of my rails project contains this line:
RAILS_GEM_VERSION = '>= 2.3.2' unless defined? RAILS_GEM_VERSION
Which makes sure that only Rails of version 2.3.2 or greater will be used to run this app.
Is there a way of specifying both the lower and the upper boundary at the same time? So that it would run, say, only on versions higher than 2.3.1 and lower than 2.3.6?
Hello friends i am moving from php to ruby on rails. Suppose u want to create a application in ruby on railsrails depot -d mysql
This will create a application depot with database mysql right..!!!
Now config/database.yml has a definition of three databases ie depot_development, depot_test and depot_production under environment development , test and production respectiviely
Whats the significance of creating these three databases.. (Please explain considering this is my first day with ruby on rails and i am takin help from Agile Web Development with Rails)
I'd like to build a webapp in Rails in which I'd like to determine every pixel's color of a given image (JPEG). Is there any possibility to do that with Rails or JavaScript? The goal is to write an algorithm which determines the "middle color" of the image and uses it for background color of the site.
Any suggestion would be appreciated.
Is there a way to start a Rails 3 development server (rails server) that is not bound to a specific IP address? I'd like for others working on a project with me to be able to use the application from remote locations.
I saw this post but mine is slightly different:
http://stackoverflow.com/questions/1559879/rails-actionmailer-with-multiple-smtp-servers
I am allowing the users to send mail using their own SMTP credentials so it actually does come from them.
But they will be sent from the Rails app, so that means for each user I need to send their emails using their own SMTP server.
How can I do that?
I have a requirement where in I want to redirect to an external Url
Here is my code
in routes.rb
map.connect "/myapp/:someparam" ,
:controller = "foocontroller" ,
:action = "redirect_to_external_url"
In my foo controller i have this action
def redirect_to_external_url
redirect_to "http://externalurl.com/#{params[:someparam]}.html"
end
which will redirect to the external url
The problem That I am facing is
After redirecting, The browser shows "http://externalurl.com/bar.html whereas I want the browser to show "/myapp/bar" url (ex http://mydomain.com/myapp/bar) for seo purpose.
Any idea on how this can be achieved in rails ?
The Rails version that I am using is 2.3.4
I want to be able to edit and delete resources myself, but not allow users of the application to do so.
Is there an easy way of doing this in Rails?
An incomplete solution would be just to remove the "delete" and "edit" buttons from the index view, but that doesn't disable their ability to do so via direct HTTP requests.
Running Rails 2.2.2 and ruby 1.8.7
I have ruby on rails installed on my ubuntu 8.10 desktop. Script/generate came up with this error.
# script/generate
undefined method `index' for #<Enumerator: "Rails Info:":each_line>
any ideas?
Thanks for you help,
zeem