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.
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.
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 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
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'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.
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 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?
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.
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!
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,
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!
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?
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.
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?
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)
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 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 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 store some information about my rails application, like a version number. I am new to rails and I'm sure there is some sort of convention for doing this. What is the best method of doing this, maybe the environments file?
Is it possible to start an AMQP subscriber with my Rails app? Possibly through an initializer or something.
I'd like to have it running at the same time that can also interact with Rails models. Below is a pseudo-code example of what I mean.
queue.subscribe do |msg,body|
Foo.create(....)
end
I have a rails webapp which internally connects to another request server. At times , ruby process gets stuck in close_wait state and stop responding and needs a restart. i guess this happens only when the request server which the rails app connects to is restarted. But am not completely sure of it. Any help appreciated on how should i go about debugging this issue.
Thanks.
I have a controller Projects in my Rails app with:
caches_page :index
However, instead of the cached file being generated at /public/projects/index.html it is located at /public/projects.html.
The web server (currently Mongrel) looks for */ directories before *.html files. So the http://…/projects request is routed through Rails and my index cache file is never served.
How can I tell caches_page :index to generate the file at /public/projects/index.html instead?
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