Hi,
I want to do something similar to the question here:
http://stackoverflow.com/questions/848034/grouping-views-controllers-models-in-mvc
But in Ruby on Rails. And the catch is, Models are to be grouped in a folder, but Controllers and Views are to be put in different folders, say admin/ and store/ folders.
Tried to separate these i...
I have a rails app that has a private component and a public component.
www.hostname.com/ is private and should only be accessed from inside our firewall, but i want to allow access to www.hostname.com/public to internet users. I played around with the apache vhost config but it seems when I allow access to www.hostname.com it allows ...
Hi,
I'm trying to redirect from one controller to another in Rails and I am getting this error:
undefined method `call' for nil:NilClass
The code is pretty simple (in def create method):
@blog_post_comment = BlogPostComment.new(params[:blog_post_comment])
respond_to do |format|
if @blog_post_comment.save
flash[:notice] = '...
I have a Rake task that loads configuration data into the DB from a file, is there a correct ruby/rails way to call it on a migration up?
My objective is to sync my team DB configs, without have to broadcast then to run the task lalala
def self.up
change_table :fis_situacao_fiscal do |t|
t.remove :mostrar_endereco
t...
Note: This is a "railsier" (and more succinct) version of this question, which was getting a little long.
I'm getting Rails behavior on a production server that I can't replicate on the development server. The codebases are identical save for credentials and caching settings, and both are powered by Oracle 10g databases with identical s...
Hey,
I'm trying to achieve URLs like this in Rails:
http://localhost/posts/1234/post-slug-name
with both ID and slug name instead of either
http://localhost/posts/1234
or
http://localhost/posts/post-slug-name
(right now I have just slug name in URL, so this part is over). How can I do this?
UPD
I found an article on this: htt...
So I am trying to use jQuery to insert data from an ajax call.
I actually use the jquery.form plugin, and have the ajax form submitted with a dataType: 'script'.
The response is a jquery expression which contains a <%= javascript_escape(render ...) %> erb tag (similar to what the railscasts episode 136 instructs to do). However the end...
I want to print some objects in a table having 2 rows per object, like this:
<tr class="title">
<td>Name</td><td>Price</td>
</tr>
<tr class="content">
<td>Content</td><td>123</td>
</tr>
I wrote a helper method in products_helper.rb, based on the answer of this question.
def write_products(products)
products.map {
|prod...
Is HTTP digest authentication still supported in Rails 3?
I tried the following code in Rails 2.3.5, it works.
class Admin::BaseController < ApplicationController
before_filter :authenticate
USERS = { "lifo" => "world" }
def authenticate
authenticate_or_request_with_http_digest("Application") do |name|
USERS[name]
e...
I am new to Ruby and Rails so bear with me please. I have created a very simple blog application with both posts and comments. Everything works great. My next question regarding adding categories. I am wondering the best way to do this. As I can't see too far in front of me yet when it comes to Rails I thought I would ask.
To be clear,...
I am displaying recent comments on the home page of a very simple blog application I am building in Ruby on Rails. I want to limit the number of characters that are displayed from the 'body' column of the comments table. I am assuming I can just add something to the end of the code for <%=h comment.body %> but I don't know what that woul...
I have two Models, Modela and Modelb.
Modela can only own one Modelb, but Modelb can be a part of many Modela's.
What I have right now is
class Modela < ActiveRecord::Base
has_one :modelb
end
class Modelb < ActiveRecord::Base
belongs_to :modela, :foreign_key => "modela_id" #might not make sense?
end
Not too sure about the whole...
I get the following error when testing a named route
1) Failure:
test_settings_route(ProjectsControllerTest) [/test/functional/projects_controller_test.rb:15]:
The generated path <"/projects/1/edit"> did not match <"/projects/1/settings">
Here's the test and what I put in my routes file
# projects_controller_test.rb
require 'test_h...
I want to hide the urls for editing users and their profiles behind safer and meaningful urls. For instance, I want /user/13/edit to be /settings/account and /user/13/profile/edit to be /settings/profile.
I managed to achieve that, but for that I had to load the user information from the current_user bit from the session. Like so:
# u...
I have a rails application that I need to deploy to 3 servers - machine1.com, machine2.com and machine3.com. I want to be able to deploy it to all machines at once and each machine individually. Can someone help me out with a skeleton Capistrano config file / recipe? Should it all be in deploy.rb or should I break it out in machine1.rb, ...
Hello, I am working on an application where a user has the ability to leave feedback on another user. Currently, I already have an implemented user model.
Is this considered a self referential association?
This seems a bit wierd to me (how to set it up through Active Record Associations).
How would I go about setting this associatio...
What's the best way (ideally a gem, but a code snippet if necessary) to generate an HTML table from an array of hashes?
For example, this array of hashes:
[{"col1"=>"v1", "col2"=>"v2"}, {"col1"=>"v3", "col2"=>"v4"}]
Should produce this table:
<table>
<tr><th>col1</th><th>col2</th></tr>
<tr><td>v1</td><td>v2</td></tr>
<tr><td>v...
Is there an easy way to see the actual SQL generated by a rails migration?
I have a situation where a migration to change a column type worked on my local development machine by partially failed on the production server.
My postgreSQL versions are different between local and production (7 on production, 8 on local) so I'm hoping by lo...
Hi
I wanted to know if their is any tool that can be used to create sql migration script of existing database in Ruby on Rails.
Also is their any visual tool that can be used to write Ruby on Rails migration script.
...
I'm learning how unit testing is done in Rails, and I've run into a problem involving Authlogic.
According to the Documentation there are a few things required to use Authlogic stuff in your tests:
test_helper.rb:
require "authlogic/test_case"
class ActiveSupport::TestCase
setup :activate_authlogic
end
Then in my functional tests...