ruby-on-rails

How to add the prototype library in all web pages?

I have several pages that using the prototype library, so, I added " javascript_include_tag 'prototype'" in my RoR application. But I want to DRY my code. Is there any way, like a root page, and all view is subclass from this page, that allow me to add this once, and all my view will get the javascript_include_tag 'prototype' automatical...

Controlled access and routing

I have a rails application and I want to manage access to the application in a controlled way. The client user would have access to only certain views in the application, whereas the admin can access any page. In future, I may also add some semi-admins who might have access to a subset of pages that were accessed by the admin. I already ...

Delayed Job on Heroku

I have a Rails application hosted on Heroku that requires a weekly data import. The task is performed by administrators and takes about 1-2 minutes to run (compute time). On Heroku, jobs that require more than 30 seconds time out. Heroku recommends job queues - however paying $36.00 per month (price of one worker) for 8 minutes of comput...

In RoR, if I say that A has_one B, is it mandatory that A has one B?

I need to setup a relationship so that A has one B, but there will be some entries where A doesn't have a B. Is this possible? If not, how can this be done? Thanks for reading. ...

Howto show ping output dynamically in a web page?

As part of a diagnostics page I would like to have the user be able to run a "ping", ie an ordinary shell command to send ICMP_ECHO_REQUSTs to a certain IP and display the resuls dynamically in a div in the browser. The backend is Ruby/Rails. I'm past running the command on the server side and reading the output from the ping command. ...

How can I localize will_paginate in ruby on rails?

Good morning :), I like to localize the "previous" and "next" links in will_paginate, how can I do that? Did anyone find a nice workaround? Thanks in advance cheers tabaluga ...

Help with group by clause

When i write the following code Post.find(:all,:group=>'comments') It only gives me the first record with the matching no of comments and skips the other records with the matching no of comments. On the other hand, if i do something like this Post.count(:all, :group=>'comments') It gives me #<OrderedHash {1=>9}> which means tha...

Why I can't alert somethings on the browser?

I have a login method, I would like to say a alert, when the user success login... This is the remote form: <div id="login"> <%if logged_in? %> <b><%=current_user.login%></b> <%=link_to "Signout", logout_path%> <%else%> <% form_remote_tag :url => session_path do -%> <p><%= label_tag 'log...

Where I got a NoMethodError using restful authorization??

This is the code from my login Page: <%= flash[:notice]%> <h1>System</h1> <%= Time.now%></p> <p><%=link_to "Register", signup_path%></p> <div id="login"> <%if logged_in? %> <b><%=current_user.login%></b> <%=link_to "Signout", logout_path%> <%else%> <% form_remote_tag :url => sessio...

RoR form_for: Hidden field isn't being included within the object paramater and therefore doesn't work.

I'm using a form to add an entry, and I need to send the id of the current user along with the entry parameters. Here is my form code: <% form_for(@entry) do |f| %> <%= f.error_messages %> <%= hidden_field_tag 'user_id', current_user.id %> <p> <%= f.label :date %><br /> <%= f.date_select :date %> </p> <p> <%= f.labe...

Post Params to External Site with Link_to

I have a shop application and another site thats for a special promotion. I've used Active Resource to import products from the shop in to the promo site and added a shopping cart to add the products. However, to actually order the products I need to send the items to the shop application, creating a new cart there to finish the order. ...

Rails charachter encoding problem view to controller

The character encoding starts to irritate me. It took me a while to get everything from the DB in the right encoding on the screen, but with help from the i18n helper, this worked out. Now I only have one more problem: saving text... If i add some letters with accents (eg é ç ...) in a text field and want to save it, already in my contro...

RoR - The views in one of my controllers are not displaying the application layout for no apparent reason

For one of my controllers, all of the views are displaying without the application layout. The application layout works fine for every other controller & view in the application. Here is a controller whose views display the application template (note: I've made all of the views empty to simplify matters) class PagesController < Applica...

How do I order associated objects with searchlogic in views?

Hello again great knowledge masters of stackoverflow, once again the small coder apprentice tabaluga is in need of help The Goal : make the username sortable in the view. The difficulty is, that I am Querying Profiles in the controller ( Profile.username doesn't exist but Profile.user.username does). How Do I accomplish that? My Code so...

Closed Stream error on my ROR application.

Please help me most of the time time i face these type of problem. Closed Stream error on my rails application. ...

Update mongodb document without updating embedded document and vice versa

Hi I have a document with an embedded document in it. I have 2 forms, 1 that updates fields in document and one that updates fields in emdedded docs. They are split into 2 forms as lots of fields in each etc and actually this is just a simple example of the structure of my app. Everywhere else that i reference this data it makes m...

Prevent Duplicate Entries and alert via a alert box if user insert duplicate entry.

How i Prevent Duplicate Entries in database at the time of form submit and display an alert box and stop form submission if entry is duplicate. ...

Accessing Mongrel on Ubuntu within a Windows VM

Hej, i'm developing on an Ubuntu 10.04 Version. I'm using Mongrel 1.1.5. To test crossbrowser compability i want to access my local server directly out of a VM (Virtual Box OSE) runnning Windows XP Prof. Network connection is established, a ping from Windows to ubuntu shows that the connection is established, but when i try to access ...

Web Framework - Ruby on Rails or Django for beginner?

I am still new to web framework and I am thinking of choosing either Ruby on Rails or Django. Which one should I go for as a beginner? ...

HTML code in Rails YAML-fixtures

HI, i have an "Article" model, that has HTML as it's content. I have created some test data with YAML fixtures and faced following problem: As i say "rake db:fixtures:load", following error appears: ArgumentError: syntax error on line 22, col 0: <li>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ...