There is an ApplicationHelper in an engine we're using that looks like this:
module ApplicationHelper
def page_title()
# ...
end
end
This gets called by a number of views in the engine. I'd like to override this method in my application to provide a different default title. How do I do this? Simply defining my own ApplicationH...
I've put all of my user-authentication code in one place, namely lib/auth.rb. It looks like this:
lib/auth.rb
module Admin
def do_i_have_permission_to?(permission)
# Code to check all of this goes here
end
end
I include this module as part of the application helper, so these functions are available in all the views:
appli...
I am used to use the helper methods link_to_remote and friends to create links or buttons that will send Ajax request under the hood and update some data of the webpage.
I have some which background images are buttons. I want them to send Ajax request to my rails server.
I guess a javascript onClick + sending Ajax request should do t...
Given a model that has validations in the model_name.rb file, how can I access those validations manually? I'd like to cook up my own form validation system that would work alongside the built-in Rails tricks and I want to keep everything as DRY as possible. My main problem is that I need to make server-side validations before any of the...
Hello, I have a model, Feed, that has and belongs to many FilteredUsers. In this case I have implemented it through a has_many :through relationship.
class Feed < ActiveRecord::Base
has_many :denials, :dependent => :destroy
has_many :filtered_users, :through => :denials
I would like to create a record if it doesn't exist or find t...
I have a data model in my Rails project that has a serialized field:
class Widget < ActiveRecord::Base
serialize :options
end
The options field can have variable data info. For example, here is the options field for one record from the fixtures file:
options:
query_id: 2
axis_y: 'percent'
axis_x: 'text'
units: '...
I have form in views/users/show.html.erb
<% form_for [@user,Wall.new] do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :message %><br />
<%= f.text_area :message,:rows=>4 %>
</p>
<%= f.hidden_field :sender_id,:value=>current_user.id %>
<p><%= f.submit "Submit" %></p>
<% end %>
and I have this validation method in Models/wall.rb
vali...
I would like to limit the size of the stack traces I am seeing in Rails. I'm not really interested in debugging the Rails stack as much as my own application. Is there any built-in way to have Rails do this dynamically?
...
I'm using the following code as a link to delete a todo in a simple todo list application I'm making:
<%= link_to_remote 'delete', {:url => complete_todo, :confirm => 'Are you sure?', :method => :delete}, { :href => url_for(complete_todo), :method => :delete } %>
It works fine when JavaScript is enabled, but when it's disabled it make...
Hi,
Total noob question. Would greatly appreciate any pointers.
I have a rails model that includes 2 possible values for a concept, e.g., distance (a value from a GPS file and an edited value). It's possible to have a value in either column (just file or just manual), both (manual overwrites file in this case), or neither:
distance-f...
Hi All,
I have a rails app that has asynchronous processing, and I'm having trouble getting it to work in production mode. i start starling from the root of the application like so:
starling -d -P tmp/pids/starling.pid -q log/
then i start workling like this
./script/workling_client start -t
the first time i ran this, it complain...
Pretend I have a model, Post which has_many :comments. How can I only display posts that have comments?
I am somewhat comfortable with named_scope but I don't know how I can put Post.comments (or self.comments) in the :conditions hash which expects symbols.
class Post < ActiveRecord::Base
has_many :comments
named_scope :with...
Hi, I am using Pommo for my mailing list, unfortunatelly Pommo doesn't provide an HTTP API but provides and embedable subscription form I can put on my site. But posting using that form takes me out of my site and that is unacceptable for me.
So I want to do the field validation in Rails and then use curl to post the values.
The fields...
I need to create documentation for my rails models. I can't figure out how to get the Rake doc:x commands to include the validators and relationships. I'm using annotate_models to document the table structure.
It would be great if there were something like RailRoad that worked with 2.3.x series as well.
...
Using Ruby on Rails, I have created a blog. The blog has posts, and comments associated with each post.
I want to add a name field to the comment controller (or model, not sure), so that the commenter is identified. Since right now it's just a comment that's being added. The name field should be stored in the database.
What is the b...
hi all
I have a product model that has many sections and a section can belong to many products.
The section model has subclasses as features, standardAccessories and OptionalAccessories in a STI. Each having field title, body, image url and (optionalAccessories) has price.
my models are
class Product < ActiveRecord::Base
has_and...
One of the things I like about Netbeans Ruby development is keyboard triggers.
For example, if you are in an erb template and you type:
licai
After you hit the tab key, this text gets replaced with:
<%= link_to "${1 default="link text..."}",
:controller => "${2 default="items"}",
:action => "${3 default="edit"}",
:id => ${4 defau...
I'm using slimbox2 with rails. To make it work you include some markup as follows:
<a href="resources/images/weight1.jpg" rel="lightbox-a" title="Beautiful, isn't it?">a</a>
<a href="resources/images/example.jpg" rel="lightbox-a" title="Beautiful, isn't it?">a</a>
So I'm wondering, how do you grab the location of the image to place ...
I am trying to write some functional tests in my rails app, and in the application_controller.rb I have this:
before_filter :current_account
def current_account
@current_account ||= Account.find_by_subdomain!(request.subdomians.first)
end
When running tests, request.subdomains doesn't contain the valid subdomains I'm looking for and...
After following http://kenai.com/projects/jruby/pages/JrubyOnRailsOnTomcat#Rails_2.0
though with tomcat 5.5, jruby 1.3.0, rails 2.3.2
tomcat gives:
SEVERE: unable to create shared application instance
org.jruby.rack.RackInitializationException: Please install the jdbc adapter: gem install activerecord-jdbc-adapter (no such file to load...