Form validation with jQuery is as easy as adding a classname to a field. Form validation with rails is as easy as putting a condition in to your controller (and/or model).
I figure there should be a way to write the validations once and have them applied both client and server side. I've always been a fan of writing my own javascript,...
I have a User model and Posts model. I want to display the posts belonging to each user,
via a URL say http://localhost:3000/my_posts/1" but Rails is reporting error saying
that no matching route exits for
http://localhost:3000/my_posts/1.
Rails looks at the complete url : "http://localhost:3000/my_posts/1" as a route , but my
i...
Well, I've been trying to change the default theme of spree by following this tutorial
http://blog.endpoint.com/2010/01/rails-ecommerce-spree-hooks-tutorial.html
But the homepage doesn't change at all, well since the tutorial is meant for rails 2, I'm just wondering what do I need to change from the tutorial to make it work with rails ...
I'm building a Rails 3 web application and i wanna choose between restful authentication and authlogic method.
Among restful authentication and Authlogic, which one is better, based on the foolproof security , customisable and hackproof ?
...
I find that the the config/environment.rb file looks different in Rails version 3.0.
Also when i add the line "config.gem "authlogic".To environment.rb file
...
I installed authlogic and created a signup mechanism.And for creating a sign in mechanism
I tried to generate the session controlers as below but rails 3 throws error as follows.
How do I create the user_session and proceed with authlogic in rails 3 ?
:~/work_space/rails_apps/sample_authentication$ rails generate session user_session
...
I have a table with a user_id field. In find, I created a join
on user table to retreive the username as:
@question = Question.find(params[:id], :select=>"questions.*,
users.username as username",:joins=>" inner join users on users.id =
questions.user_id");
I created an instance variable in Question class with name
username. But I...
Hi,
I'm trying to an activemodel instance with translations. I find that the only way validations work (with another locale) is by duplicating the error message for every field I defined int he model. So for this model:
require 'active_model'
class User
include ActiveModel::Validations
attr_accessor :first_name, :last_name, :email...
I'm writing a Rails ActiveRecord model that needs a weaker version of validations. Essentially, the flow goes like so:
Email is received and parsed by application. (already handled)
Input from email is used to create/populate new model instance. (already handled)
Model is checked for a series of conditions. (conditions already wr...
I have post and user model and I have Many(posts) to One(User) association.
I want to display only the posts which are created by that user(current user).
So somehow I have to inject the currently logged in user's id into the "user_id" foreign key
of the post model during creation. I'm using Devise as my authentication system.
Any solut...
My app has a navigation bar with options:-
"create post", "Show posts owned by me", "Show All posts"
But of I navigate to the page "show posts owned by me", the navigation bar should no longer
display the option "show posts owned by me". Is the any api such as current_url_path so that
I can compare current_url_path api's output with...
For example consider the following output from rake routes:-
posts GET /posts(.:format) {:action=>"index", :controller=>"posts"}
posts POST /posts(.:format) {:action=>"create", :controller=>"posts"}
*new_post* GET /posts/new(.:format) ...
Hello, in my users model, I have the following:
@users = find(:all, :joins => :instance, :conditions => ['fname LIKE ? or lname LIKE ?', "%#{search}%", "%#{search}%"])
The issue here is that @users only returns data from the user's table, and not the joined instance table. I confirmed this with the SQL query in the logs.
SELECT "use...
Hi,
I'm trying to use rails 3 without any db backend, but it still insists on requiring 'sqlite3' gem when I try to access a page, and throws an error no such file to load -- sqlite3, even though no code in the application requires sqlite, except I left database.yml with its default setting for sqlite3, since removing the content raised...
Here's what I have today:
I output a list of @users
What I need to do is output a list of users and say if they are assigned to the current project.
I could loop through each user and check in the database, but that would be a lot of data base hits, an additional 10 hits for displaying 10 users.
My question to you, is there a smart, m...
My :post model is the parent model. Within a post are many comments. And comments have potential of having many more comments, and so forth. I thought I had had this right, but I were to type :
Comment.last.comments
I get :
NoMethodError: undefined method `comments' for #<Comment:0x1053a1ff0>
My Models :
#comment.rb
belongs_to ...
I tried rake stats but that seems highly inaccurate. Perhaps it ignores several directories?
...
I have users in my system that can elect to 'hibernate', at which point they can remove themselves and all of their associated records entirely from the system. I have queries all over my site that search within the User table and its associated tables (separated by as many as 5 intermediate tables), and none explicitly test whether the ...
I am trying to learn TDD, but getting RSpec + Autotest setup on Windows 7 has been a pain.
Does anyone have any good resources that can point me in the right direction of getting this thing setup, so I can continue learning how to do TDD in Rails?
Thanks.
...
I'm developing a simple event management/ticketing application for LAN parties. I have a need obviously to have the user buy tickets for events.
Currently, a User visits an Event page and selects a Ticket. After the user pays for the Ticket, a Registration is created and the User is permitted to further interact with other Users and the...