ruby-on-rails

Is there any analog of django's forms in Ruby on Rails?

Hi guys, Is there any analog of django's forms in Ruby on Rails? Thanks, Alexey Zakharov ...

Dynamic Sidebar with Rails layout

For instance, i want to have my sidebar to have several dynamic content. Using other method will lead me to put query codes into View, which is not a good idea at all. I would like to keep any query in my Controller. Currently as i know there are several ff. method: Render a shared partial -> No where to put the query render :partial ...

How to use restful_authentication for nested resources in Rails 2.3.8 ?

I have a nested resource hotel_user and i wish to have hotel_users_controller under hotel namespace. I want to use restful authentication here and I want hotel_users_controller, sessions_controller in hotel directory like hotel/hotel_users_controller and hotel/sessions_controller. I tried with the following command in terminal and it f...

Ruby update action not working

I have one model: new and its controller: news The news controller methods: def edit @new = New.find(params[:id].to_i) end def update @new = New.find(params[:id].to_i) @new.update_attributes(params[:new]) flash[:notice] = "Sikeresen frissítve" redirect_to news_path rescue ActiveRecord::RecordInvalid f...

Elegant PostgreSQL Group by for Ruby on Rails / ActiveRecord

Trying to retrieve an array of ActiveRecord Objects grouped by date with PostgreSQL. More specifically I'm trying to translate the following MySQL querry: @posts = Post.all(:group => "date(date)", :conditions => ["location_id = ? and published = ?", @location.id, true], :order => "created_at DESC") I am aware that PostgreSQL ...

Building association proxies with through

Taking this article as a starting point: Rails Way Blog - Association Proxies and looking specifically at def create @todo_list = current_user.todo_lists.build params[:todo_list] if @todo_list.save redirect_to todo_list_url(@todo_list) else render :action=>'new' end end This is a way of making sure you assign ownersh...

Rails variable loads first time and then is nil!

I am receiving the following error: ActionView::TemplateError (You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include?) on line #24 of app/views/index/index.html.erb: 21: <% @achievements.each do |achievement| %> 22: <%= achievement.name %> 23: ...

Combining Option Routes in Rails 2.3

I'm tring to setup a Route like so: GET /settings/ PUT /settings/ GET /settings/photos PUT /settings/photos This is the routing code that I have setup for it: #I just do this for code reuse get = { :method => :get } put = { :method => :put } pub.settings '/settings', :controller => :settings, :action => :index, :conditions => get pub...

showing error when i customized will_paginate

i want the pagination to look like this "1 prev5<< prev< 6 next> next5>> 50" 1 means first page 50 means last page 6 means current page so i customized the code somewhat like below in config/initializers/ PaginationListLinkRenderer (created new file to customize) module WillPaginate class PaginationListLinkRenderer < LinkRe...

Rails inconsistently fails to send datetime parameters

I am revising someone else's project which allows users to submit content either for either immediate or scheduled publication. There are a pair of radio buttons to select this, and a datetime field that is enabled by javascript if the radio button for 'scheduled' is selected <%= f.hidden_field :scheduled_state %> <%= f.radio_button :im...

Ruby on rails, devise, how to set up a user profile

I'm new to rails, and even more new to devise. I have set up a user controller and I've managed to create a view showing the e-mail address of the current user. Now I want a user profile page, where the user can add personal information etc, and keep track of published posts etc. Basic community functions. How should I design this? Sho...

Problem deploying frozen Rails app - "could not find RubyGem rack"

I have a rails app which I develop on Windows with Rails 2.3.5, using sqlite3 as my database engine, and the internal Mongrel server as my webserver. I deploy this app to a hosted Linux machine running Rails 2.1.0, using Postgres as my database, and Apache (calling dispatch.cgi) as my webserver. I do not have permissions to update the n...

Is there a way to actively monitor HTTP requests on Rails, to direct the request to another mongrel if it times out?

Hi, I am working with a client who's server admin refuses to install monit or god on their webserver to restart locked or slow mongrels / threads as they reckon the application should just work flawlessly and threads should never lock / go slow. Unfortunately their app makes a lot of calls to 3rd party webservices, many of which are sl...

Turn underscored names in Rails into 'pretty' text (Like ActiveRecord)

I have a real simple question here. I only want to know if there is an existing Rails way to accomplish this, because I don't want to re-write something that is already in the framework. Think of an underscored variable name like "this_is_an_example". Is there a quick way to turn that into "This is an example" or even "This Is An Exampl...

Is Rails 3 modular like Merb and Ramaze

Hey, Will Rails 3 be a modular framework like Merb or Ramaze? By this I mean, can we use any persistence framework (DataMapper or Sequel) and jQuery in Rails 3 application (via the command line for example)? Or the default stack (ActiveRecord, Prototype) is still enforced? (Sorry, I'm pretty new to Ruby/Rails community). Thanks. ...

Can't turn array into a string error

I have a simple call JSON.parse(Panda.get("/videos/#{self.panda_video_id}/encodings.json")) Which returns : can't convert Array into String This is because the Panda.get("/videos/#(self.panda_video_id}/encodings.json") call returns an array in the new Panda 1.0.0 gem. I also tried : JSON.parse(Panda.get("/videos/#{self.panda_vi...

System DSN not working when running Rails as Windows Service

When I run the mongrel server in a command window everything works fine, database connections are made and the app is running properly. If I set the Windows Service to run my app by logged in with my user credentials it works fine as well. However, when I set the Service to run as Local System I cannot get the application to start an...

rails HABTM migrations

From a practical and best practices perspective, should rails models that have HABTM association also have a defined model for example users_groups.rb. So, should you script generate model ... or simply script generate migration ... On one hand the join table is simply two fields and shouldn't have any methods of its own, on...

Unable to use I18n.t call in an initializer file

I would like to use I18n.t call in an initializer file. Unfortunately, it doesn't work. Rails returns the usual "translation missing:" message. It seems that the I18n files haven't been loaded yet when the call is made. Are there any workarounds ? Thanks ...

Flex AsyncToken implementation on Rails

Hi there, i'm using a Rails backend with my App and getting a AsyncToken returned from it (a DB-Call to be specific) As far as i know the AsyncToken returns a result event when done loading all data from the request, this way its possible to make sure all data was loaded before executing some function which uses the data. i tried the ...