[Rails] Re: jeditable make entire table row editable

2011-08-25 Thread Leonel *.*
Yeah, looked into them, they make my brain explode =P -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from

[Rails] Re: Use find with a variable

2011-08-25 Thread Leonel *.*
This is making me crazy, even if I do... <%= a %> I get... # But as soon as I try to access the cost or name attributes I get... undefined method `cost' for nil:NilClass and it's NOOT NIIILL!!! >:( -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscr

[Rails] Re: Use find with a variable

2011-08-25 Thread Leonel *.*
This is very weird, even if I do a.methods, "cost" is there! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscrib

[Rails] Re: Use find with a variable

2011-08-25 Thread Leonel *.*
So, I do find the "part", using a = Part.find_by_id(the_id) If I do <%= debug a %> I get... -- attributes: name: Western Digital - Caviar GP 500GB Internal Hard Drive created_at: 2011-08-23 18:54:12.214873 cost: 49.99 updated_at: 2011-08-23 18:54:12.214873 id: 2 [..

[Rails] Re: Use find with a variable

2011-08-25 Thread Leonel *.*
Ah! found the solution: should've used "find_by_id", instead of just "find". http://stackoverflow.com/questions/1593120/variable-passing-to-find-function-in-rails-2 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on

[Rails] Use find with a variable

2011-08-25 Thread Leonel *.*
I got the id of a "part" in variable "the_id". In a partial "_order_fields.html.erb" So I do this... @a = Part.find(the_id) I get this error... Couldn't find Part without an ID So I also try... @a = Part.find(the_id.to_i) Get same error. If I do @a = Part.find(2), it works. But I need to do th

[Rails] jQuery makes the Delete link stop working

2011-08-25 Thread Leonel *.*
I have an usual index.html.erb file generated by the scaffold. If I include jquery-1.6.2.min.js, the Delete link stops working. If I remove jQuery, the Delete link starts working again. Anyone experience anything similar? Do you know a solution? -- Posted via http://www.ruby-forum.com/. -- You

[Rails] Re: Get selected value from a collection_select

2011-08-25 Thread Leonel *.*
It's a form. Has a drop-down menu, created by a collection_select. Since it's an edit page, then the value is ALREADY SELECTED by the time you get to that edit page. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby o

[Rails] Get selected value from a collection_select

2011-08-24 Thread Leonel *.*
I have an edit form and I need to get the SELECTED VALUE from a collection_select in a variable. So if I have this... <%= f.collection_select :part_id, @parts, :id, :cost_and_name, :prompt => "Select" %> How can I peek inside and get, for example, the part_id? -- Posted via http://www.ruby-for

[Rails] Re: has_many through association

2011-08-24 Thread Leonel *.*
T. N. T. wrote in post #1018286: > Leonel *.* wrote in post #1018279: >> ... >> has_many :tickets, :through => :orders >> >> order.rb (this table has two columns: ticket_id and part_id) > > If this table really has only those two columns a simple > has_an

[Rails] has_many through association

2011-08-24 Thread Leonel *.*
I have 3 models: ticket, part, order ticket.rb has_many :orders has_many :parts, :through => :orders accepts_nested_attributes_for :orders accepts_nested_attributes_for :parts part.rb has_many :orders has_many :tickets, :through => :orders order.rb (this table has two columns: ticket_id and part

[Rails] Re: jeditable make entire table row editable

2011-08-23 Thread Leonel *.*
please help -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-tal

[Rails] jeditable make entire table row editable

2011-08-22 Thread Leonel *.*
jeditable helps you click on a table cell and edit it. but how could i click anywhere on the cell and make all the cells in that row editable? I have searched for about 3 hours and tried a few things and i can't seem to get it. has anybody done it before? can u point me to the right direction? e

[Rails] Re: Re: Validates attributes that aren't even being changed

2011-08-22 Thread Leonel *.*
Chirag Singhal wrote in post #1017423: > Try this > > :unless => Proc.new {|user| user.password.nil?} > > Essentially it will check if you are sending a password attribute to the > user or not while updating the user record and will check for this > validation only if password attribute is present.

[Rails] Re: Validates attributes that aren't even being changed

2011-08-18 Thread Leonel *.*
Can someone help me complete this piece of code? I'm thinking about using :unless because the only place where I wouldn't like the password validation is in the Edit User page. validates :password, :presence => true, :length => { :minimum => 6, :maximum => 20, :message => 'should have between 6

[Rails] Re: Validates attributes that aren't even being changed

2011-08-18 Thread Leonel *.*
I temporarily solved the username attribute by not letting the user update the username. So the validation only works :on => :create So username attribute validation problem solved. Now I got the password validation problem. Ok, it seems the problem was kinda of obvious but I couldn't see it. I

[Rails] Re: Re: Validates attributes that aren't even being changed

2011-08-12 Thread Leonel *.*
> As I said in my previous post VALIDATIONS ARE NOTHING TO DO WITH DATA > IN FIELDS ON THE FORM (yes, I can shout too), so it doesn't make any > difference whether username is on the form or not, the validations are > still run on all fields that are being written. Perhaps you had > better read my

[Rails] Re: Re: Set value in controller from a form

2011-08-12 Thread Leonel *.*
>> I have this in users_controller.rb >> - >> @user = @company.users.build(params[:user]) >> @user.invitation_last_sent_at = Time.now >> @user.invitation_last_sent_to = ??? > > What? You have that line if the controller? No, I meant I tried those 3 diff

[Rails] Re: Validates attributes that aren't even being changed

2011-08-12 Thread Leonel *.*
Thanks to everybody for their comments, it's helping me understand Rails more :) I'm going to try your suggestions. > Colin Law wrote in post #1016307: > Having said that I do not understand your comment above, you say you > get the problem when you try to change the username, but then say that

[Rails] Re: Validates attributes that aren't even being changed

2011-08-11 Thread Leonel *.*
Well yeah but even if I take :on => :update away it'll still run the validation, right? I've read that Rails runs the validation on "update" and "save" unless you specify otherwise. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Googl

[Rails] Validates attributes that aren't even being changed

2011-08-11 Thread Leonel *.*
I have a form where I can only update the user's first name, last name and email address. I have this in the user model file, user.rb validates :username, :presence => true, :uniqueness => true, :on => :update validates :password, :presence => true, :length => { :minimum => 6, :maximum => 20}, :

[Rails] Re: Set value in controller from a form

2011-08-11 Thread Leonel *.*
Is it maybe because it's a nested resource? I have this in users_controller.rb - @user = @company.users.build(params[:user]) @user.invitation_last_sent_at = Time.now @user.invitation_last_sent_to = ???

[Rails] Re: Set value in controller from a form

2011-08-11 Thread Leonel *.*
I'm doing it in the create action. I did use debug to inspect @user and params and that's why I used... @user.invitation_last_sent_to = @user.email @user.invitation_last_sent_to = params[:user][:email] @user.invitation_last_sent_to = params[:email] ...but none of those 3 seem to work. -- Poste

[Rails] Set value in controller from a form

2011-08-11 Thread Leonel *.*
I have a typical rails form with form_for(@user...blah blah) There is a field to enter the email address: email. But that same email address has to be entered into the invitation_last_sent_to. So the same value, in two different columns. There is no problem when saving in the column 'email' but I

[Rails] Re: Simplify code on method about 4 models

2011-08-10 Thread Leonel *.*
Thanks Fred! The reason of this setup (might need some adjusting) is that an Account has an attribute paying_method. So only the account_owner is the one that pays. The account owner can add, edit or delete Companies and Users. He's the administrator for that Account. The Users under the acco

[Rails] Simplify code on method about 4 models

2011-08-10 Thread Leonel *.*
I'm trying to get more into the Ruby mindset. I know I should accomplish more with less code. I came up with this method that does work, but I think could really use some simplification. There is 4 models. Account Company (belongs to Account) User (belongs to Company) (belongs to Role) (to g

[Rails] Re: CanCan doesn't work on this model

2011-08-09 Thread Leonel *.*
Ok. This is the question I'm looking the answer for: how can I load and authorize the companies in the users_controller.rb file? I already tried load_and_authorize_resource :company @companies and @company are empty in the view. -- Posted via http://www.ruby-forum.com/. -- You received this

[Rails] Re: CanCan doesn't work on this model

2011-08-09 Thread Leonel *.*
Ok, I read the CanCan documentation more carefully and this jumped out the screen... "This will fetch the project using Project.find(params[:project_id]) on every controller action, save it in the @project instance variable..." When I was going to /users the companies resource was empty and it w

[Rails] Re: CanCan doesn't work on this model

2011-08-09 Thread Leonel *.*
I kept on simplifying the code to get to the root of the problem and it seems it won't work regardless of what I do. in ability.rb can :manage, :all so it's supposed to allow the user to do ANYTHING right? wrong! if in users_controller.rb I tried working with nested resources, it ALWAYS gives

[Rails] CanCan doesn't work on this model

2011-08-08 Thread Leonel *.*
--- ability.rb --- can :update, User, :auth_token => current_user.auth_token ---

[Rails] Re: Prevent user from abusing form

2011-08-05 Thread Leonel *.*
@robert4723 Interestind read: http://productblog.37signals.com/products/2011/01/well-be-retiring-our-support-of-openid-on-may-1.html -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to th

[Rails] Re: Prevent user from abusing form

2011-08-05 Thread Leonel *.*
Nothing complicated. It's just to stop a bot or anybody using the login or forgot password form repeatedly. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to

[Rails] Prevent user from abusing form

2011-08-05 Thread Leonel *.*
I have a Forgot my password page where the user enters his/her email. How can I prevent someone from entering different email addresses trying to guess them or spamming my users? Is there like an IP-based time expiring strategy you would suggest? -- Posted via http://www.ruby-forum.com/. -- Yo

[Rails] Re: Help simplifying code by removing some if's

2011-08-03 Thread Leonel *.*
Thanks, it did simplify it. Any suggestions on the controller? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscr

[Rails] Help simplifying code by removing some if's

2011-08-03 Thread Leonel *.*
I need some help simplifying some code. Some ago, I was trying to validate a User model depending on the action they were performing. http://www.ruby-forum.com/topic/2189458#new For example: 1) Signing up (validate presence of username) 2) Inviting someone to user the app (DO NOT validate presence

[Rails] Re: Query controller using two resources

2011-08-01 Thread Leonel *.*
Walter Davis wrote in post #1014258: > try get ':activate/:activation_code' > > Along those same lines, try User.find_by_id_and_activation_code(params) Thanks, but I tried it and I get this error when trying to start the server... Exiting /var/lib/gems/1.8/gems/actionpack-3.0.9/lib/action_dispat

[Rails] Re: Query controller using two resources

2011-08-01 Thread Leonel *.*
routes.rb --- resources :users do member do get :invitation post :activate end end 1) I go to users/78/invitation (where the form is) 2) I submit the form and goes to this url users/78/activate 3) but gives me this error "No route matches "/

[Rails] Re: Query controller using two resources

2011-08-01 Thread Leonel *.*
I'm trying to get a url like /users/45/invitation/ej3j3j (for invitation form, where you enter the password) and another /users/45/activate (for submitting the form) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby

[Rails] Query controller using two resources

2011-08-01 Thread Leonel *.*
I have an activation link. I want the user to click on the link, kinda like this... domain.com/users/45/activate/1jf872 The number after "users" would be the user id, and the string after "activate" would be the activation code. In the link above it would be user id 45 and activation code 1jf872.

[Rails] Inline form error messages

2011-07-26 Thread Leonel *.*
I've been searching for a solution to inline form error messages without using a plugin. For example, for the Email field, this is what I came up with... - <%= user_form.label :email %> <%= user_form.text_field :email %> <% unless @account.errors["companies

[Rails] Re: Display a list of methods available

2011-07-26 Thread Leonel *.*
Awesum! Thanks :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrai

[Rails] Display a list of methods available

2011-07-26 Thread Leonel *.*
For learning purposes, I want to display a list of methods available. How would I do that? For example, I found out I can do this... debug @user.errors.full_messages debug @user.errors.count How can I find what other methods are available to call on errors or any other object? -- Posted via ht

[Rails] Re: Creating 2 or 3 models in one form

2011-07-25 Thread Leonel *.*
Well, this worked. It added the account_id on companies. It added the company_id on users. It did not, however, add account_id on users. But I guess it should be ok, right? I mean, if I know which company the users belongs to, I'm still able to find out what account_id is the user from. Rememb

[Rails] user roles recommendation

2011-07-25 Thread Leonel *.*
I'm in a dilemma. I have a users table. Each user has a role: admin, manager, agent, customer. What do you recommend about the users table? Options: 1) in the users table, add a role column, type string, and enter the role as a string. 2) in the users table, add a role_id column (integer, foreign

[Rails] Re: Validation depends on Controller

2011-07-25 Thread Leonel *.*
> Instead, you could have a state column, and apply validations based on > that state. When the accounts controller creates a user, it sets its > state to (for example) signed_up, and that state requires all your > validation, whereas in the second case the controller could set the > state to 'invi

[Rails] Regular Expression help

2011-07-21 Thread Leonel *.*
I have a string composed of three parts. 1) a number, could be 1, 2, 3, 4 or more digits. 2) the word pending 3) and then a date in this format: year,month,day,hour,minute,second I would like to extract each in a variable. Examples: 7pending20110721170832 504pending20110720110107 -- Posted via

[Rails] Re: Validation depends on Controller

2011-07-21 Thread Leonel *.*
Sorry, I should've explained more. This is the general idea. There is a Sign Up form which creates 3 records in 3 different models: Account Company (belongs to account) User (belongs to user) So the Sign Up form, creates the user from the accounts_controller.rb @account = Account.new company = @a

[Rails] Validation depends on Controller

2011-07-21 Thread Leonel *.*
I know in the model we can add validations. But how about if I need different validations depending on the controller. For example... 1) if the User is being created from the accounts controller, I want to REQUIRE the username be entered. 2) if the User is being created from the users controller,

[Rails] Re: Creating 2 or 3 models in one form

2011-07-20 Thread Leonel *.*
Ok, I'm able to write to 3 models in 1 form. The code creates a brand new record in each of the three tables and writes the corresponding account_id where it's supposed to be. Everything works well, except one thing. PROBLEM: "company_id" it's not being written in the "users" table. "account_i

[Rails] Re: How to bypass required field in form

2011-07-20 Thread Leonel *.*
Thanks Bob. I did hash the password and added some salt. I based myself on the railscast "Authentication from Scratch" and also on a Rails book I have. The conditional validations railscast was VERY helpful, thanks Tom! -- Posted via http://www.ruby-forum.com/. -- You received this message b

[Rails] Re: How to bypass required field in form

2011-07-20 Thread Leonel *.*
Awesome! XD -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-tal

[Rails] Re: How to bypass required field in form

2011-07-20 Thread Leonel *.*
Aaahhrrgg! If I try to update the user attributes using irb, it doesn't do it either. Please help! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrai

[Rails] How to bypass required field in form

2011-07-20 Thread Leonel *.*
I have an Update User page. I created my own authentication from scratch based on one of the railscasts and other tutorials. The user can update his first name, last name, email address, etc. I do not want the user to update his password, so I didn't include the password fields. Since in the User

[Rails] Re: Creating 2 or 3 models in one form

2011-07-20 Thread Leonel *.*
Ok fixed it by changing the controller. build is already on 'new', so I removed it from 'create'. --- accounts_controller.rb --- accounts_controller.rb def new @account = Account.new @account.companies.build respond_to do |for

[Rails] Re: Creating 2 or 3 models in one form

2011-07-20 Thread Leonel *.*
That Railscast is good but it's not what I'm looking for. I don't want to dynamically add fields. And I just need to add one Account and one User that belongs to that account. As simple as that. To make things simpler I just tried to work with ONE field, if it works then I can add more. So afte

[Rails] Creating 2 or 3 models in one form

2011-07-19 Thread Leonel *.*
Anybody knows about an updated tutorial like this one: http://railsforum.com/viewtopic.php?id=717 That one was written in 2006 and some of it's code is deprecated. I have tried to update the code but I can't get it quite right yet. If I validate_presence_of parent_id, I get error "parent_id can't

[Rails] Re: Have Admin add users, not the Devise Sign Up form

2011-07-14 Thread Leonel *.*
Wouldn't be easier to just create the authentication from scratch? Any thoughts from anybody that has been through that? http://railscasts.com/episodes/250-authentication-from-scratch -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Goog

[Rails] Re: Devise confusing routes

2011-07-14 Thread Leonel *.*
Yep, I already understood what the problem was. For my own future reference and if anybody else runs into the same problem. Devise uses RegistrationController to create new users via the Sign Up form. If you try to add new users on your own by creating your very own User model, controller and

[Rails] Have Admin add users, not the Devise Sign Up form

2011-07-14 Thread Leonel *.*
I have Devise working. I have roles for users working. I even added custom fields to the User model and it seems that now everything is working fine. So people can now subscribe using the Sign Up form provided by Devise. But now I need Admins, to add users. Of course, I can't use the Sign Up form

[Rails] Re: Devise confusing routes

2011-07-14 Thread Leonel *.*
oh ok, well, yes maybe that's it! Maybe it was kinda obvious and I didn't see it! There is two different ways to create a new user. SIGN UP A Sign Up form, where people can subscribe to the Web App. When they subscribe, it creates an account for them and a user is created via the Sign Up form (

[Rails] Re: Devise confusing routes

2011-07-14 Thread Leonel *.*
Ok, so just moved devise_for at the top of the routes file. This is my users controller. I removed a lot of code to isolate the problem, but even without that code, it shouldn't tell me "user is already sign in" and send me to the root url. --

[Rails] Re: Re: Work with two tables in one controller

2011-07-14 Thread Leonel *.*
> You have both a regular route and a nested route for your users. Make > sure your form is submitting to the nested route. > It should look something like (depending on your variable names): > > form_for [@company, @user] do |f| > > Without the company your form will post to /users and the compan

[Rails] Re: Devise confusing routes

2011-07-14 Thread Leonel *.*
This is getting extremely frustrating! >:-( So I moved the devise_for statement, under resources users: resources :companies resources :users resources :companies do resources :users end devise_for :users, :controllers => { :registrations => 'users/registrations' } and now the fo

[Rails] Re: Devise confusing routes

2011-07-14 Thread Leonel *.*
SO you notice how it's hitting the RegistrationsController when I click the Create User button? Rendered users/new.html.erb within layouts/application (52.3ms) Completed 200 OK in 208ms (Views: 59.4ms | ActiveRecord: 0.8ms) Started POST "/users" for 127.0.0.1 at Thu Jul 14 13:21:25 -0500 2011

[Rails] Re: Devise confusing routes

2011-07-14 Thread Leonel *.*
I just remembered what fixed the Too Many Redirects error last night. I move the devise_for statement to the top of the routes file. devise_for :users, :controllers => { :registrations => 'users/registrations' } -- Posted via http://www.ruby-forum.com/. -- You received this message because y

[Rails] Re: Devise confusing routes

2011-07-14 Thread Leonel *.*
The user is logged in. So it's redirecting me to the root url with the message "You are already signed in". So I go to create new user form, I click Create User, and then redirects me to the root url "You are already signed in". This is my log: Started GET "/users/new" for 127.0.0.1 at Thu Jul

[Rails] Devise confusing routes

2011-07-14 Thread Leonel *.*
I had a similar problem yesterday. I would go to the root of my site and I would get a Too Many Redirects message. It seems like there was an infinite loop. After struggling for over an hour yesterday late at night, it seemed like I fixed it. But now, when I want to create a New User, it's redire

[Rails] Re: Work with two tables in one controller

2011-07-14 Thread Leonel *.*
I have tried in so many ways and can't get it to work. I did something yesterday that made the app have an redirect loop (too many redirects) and it took me over an hour just to fix it. So I'm just going to start all over again. My initial question had to do with other models but it's basically

[Rails] Re: Work with two tables in one controller

2011-07-13 Thread Leonel *.*
Please help, I've been trying to do this since yesterday. I'm stuck. With the above code I get error "Account can't be blank". -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this gr

[Rails] Re: Redirect to edit form after update

2010-12-03 Thread Leonel *.*
Thanks a lot guys. Yes, I'll try to understand Ruby syntax more. I studied the PDF of the unfinished version of the new Agile Web Development with Rails. After that, I bought the pickaxe Programming Ruby 1.9 book and I'm barely getting into it. Thanks -- Posted via http://www.ruby-forum.com/.

[Rails] Can't get CanCan to restrict view of items

2010-12-02 Thread Leonel *.*
So I got CanCan and Devise working well. I have two types of users: Admins and Nonadmins. Admins can view ALL appointments from the same Account or Organization. The problem is, every user (either Admin or Nonadmin) belongs to an Account or Organization. Admins should only be able to view appointm

[Rails] Re: Re: CanCan issue when being very specific

2010-12-02 Thread Leonel *.*
>> According to the wiki.. >> https://github.com/ryanb/cancan/wiki/Checking-Abilities >> >> I think you may need to change the object that can? is evaluating from the >> @user variable to the class User like so: >> >> <% if can? :create, User %> >> > > This would allow an admin to create any use re

[Rails] Re: Redirect to edit form after update

2010-12-02 Thread Leonel *.*
Marnen Laibow-Koser wrote in post #965706: > Leonel *.* wrote in post #965703: >> So instead of >> >>respond_to do |format| >> if @user.update_attributes(params[:user]) >> flash[:notice]

[Rails] Re: Redirect to edit form after update

2010-12-02 Thread Leonel *.*
So instead of respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = 'User was successfully updated.' format.html { redirect_to(:action => 'edit') } else flash[:error] = 'User was not updated.

[Rails] Re: CanCan issue when being very specific

2010-12-02 Thread Leonel *.*
Awesome! Thanks, I hadn't read that info. Works great :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe fr

[Rails] Re: CanCan issue when being very specific

2010-12-02 Thread Leonel *.*
Nothing, the New User link it's just not displaying -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from th

[Rails] CanCan issue when being very specific

2010-12-02 Thread Leonel *.*
So I got CanCan and Devise working well. I have two types of users: Admins and Nonadmins. Admins can edit all of Nonadmins profiles. The problem is, every user (either Admin or Nonadmin) belongs to an Account or Organization. Admins should only be able to edit users from their own Account or Organ

[Rails] Re: Redirect to edit form after update

2010-12-02 Thread Leonel *.*
Thanks :) I just removed the XML part and yes I did notice I had the flash in the wrong position haha. What do you mean by "I am not sure if you "really" want to conditional processing of HTTP"? I'm sorry if the question seems very basic, I'm barely getting familiar with Ruby. -- Posted via

[Rails] Re: Having trouble with CanCan

2010-12-01 Thread Leonel *.*
Nevermind, I found the problem. I was supposed to remove the @ because it's iterating from a loop: <% @users.each do |user| %> <% if user.first_name.nil? or user.last_name.nil? user_link = link_to 'User Details', user, :class=>'first_and_last_name' else user_link = link_to u

[Rails] Having trouble with CanCan

2010-12-01 Thread Leonel *.*
So I got CanCan and Devise working well. I have two types of users: Admins and Nonadmins. Admins can edit all of Nonadmins profiles. The problem is, every user (either Admin or Nonadmin) belongs to an Account or Organization. Admins should only be able to edit users from their own Account or Organ

[Rails] Re: Redirect to edit form after update

2010-12-01 Thread Leonel *.*
ALRIGHT!! AWESOME!!! Simple and it works! I did this... flash[:notice] = 'User was successfully updated.' respond_to do |format| if @user.update_attributes(params[:user]) format.html { redirect_to(:action => 'edit') } format.xml { head :ok } else ... Thanks Colin! -- Posted via h

[Rails] Redirect to edit form after update

2010-12-01 Thread Leonel *.*
By default, the controllers are coded in a way that you will be redirected to the SHOW page of the item you are updating. For example, if I edit a user, after I click the submit button, I will be redirected to the SHOW page of that users. Instead of being redirected to the SHOW page, I want to st

[Rails] Re: Compose data for a column from two fields

2010-11-30 Thread Leonel *.*
I was working on that two months ago and I thought I had everything figured out. But I stopped coding and now that I'm back I can't remember what was my plan to do that. Thanks guys! I'll try your suggestions. -- Posted via http://www.ruby-forum.com/. -- You received this message because yo

[Rails] Compose data for a column from two fields

2010-11-30 Thread Leonel *.*
I'm working on a datepicker and a timepicker. The datepicker is the jQuery datepicker. The timepicker displays a drop down menu with available times. I want to have two different fields: the datepicker and timepicker. Then mix up the two (probably in the controller) and come up with the whole date

[Rails] Re: Update password with Devise

2010-10-27 Thread Leonel *.*
This is the page http://localhost:3000/users/password/edit When I'm NOT logged in I can see it, but when IM LOGGED in it redirects me. weird -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To

[Rails] Re: Update password with Devise

2010-10-27 Thread Leonel *.*
I just found a page that is already built on Devise but it redirects me to the root when I try to access it. Is there a reason for this? The user that is trying to access that page has can :manage, :all -- Posted via http://www.ruby-forum.com/. -- You received this message because you are sub

[Rails] Update password with Devise

2010-10-27 Thread Leonel *.*
I've been googling a lot about it and can't find the solution. I have a form to edit a user, but I need to two fields to update or change their password: New Password / Confirm Password fiels. I know you can reset your password by clicking the Forgot My Password link. But I want them to be able t

[Rails] Re: Recommended Authorization

2010-10-22 Thread Leonel *.*
Decided to go for Devise and CanCan -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send e

[Rails] Re: Recommended Authorization

2010-10-22 Thread Leonel *.*
I'm going to watch a few Railscasts: OmniAuth CanCan Declarative Authorization Authlogic -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@goo

[Rails] Recommended Authorization

2010-10-22 Thread Leonel *.*
Ok, Rails is getting more and more interesting everyday I try to work with it. I had no idea how easy it is to code what you need. I could find a good existing PHP Calendar class so it took me about 2 months in "free time" chunks to write a PHP Calendar class to accomplish what I needed. Just foun

[Rails] Re: Re: Sign up (create account, create user)

2010-10-22 Thread Leonel *.*
> Manage roles with a roles model not with a model for every role, it > creates a lot of problems later on. Ok so you mean the Roles model replaced the Users and Admins model like this... Roles id email password role (admin, user) Or so you mean a Users model that connects to a Roles model li

[Rails] Re: Sign up (create account, create user)

2010-10-22 Thread Leonel *.*
Ok so I read the introductory documentation for Devise. I'm going to create an Admin controller too. What I can't find out though, I have googled it several times too, is how to apply a Layout file for a specific method of the same Class. For example, the User class: the sign up, sign in and in

[Rails] Re: Sign up (create account, create user)

2010-10-21 Thread Leonel *.*
I absolutely love Devise! Excellent recommendation! Thanks!!! XD -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubs

[Rails] Re: Re: Re: Sign up (create account, create user)

2010-10-21 Thread Leonel *.*
Walter Davis wrote in post #956070: > On Oct 20, 2010, at 11:36 PM, Leonel *.* wrote: > >>> Your Accounts will have usernames and e-mail addresses? Why? >>> Those properly belong to Users. >>> >>> Am I misunderstanding? >> Yes, a little bit :P Lik

[Rails] Re: Re: Sign up (create account, create user)

2010-10-20 Thread Leonel *.*
> Your Accounts will have usernames and e-mail addresses? Why? > Those properly belong to Users. > > Am I misunderstanding? Yes, a little bit :P Like I said above... "The user that signs up and creates the account is the admin user for the account. Then, he can send email invitations to his staff

[Rails] Re: Re: Sign up (create account, create user)

2010-10-20 Thread Leonel *.*
Walter Davis wrote in post #955927: > On Oct 20, 2010, at 5:34 PM, Leonel *.* wrote: > >>> What should be getting validated? >> Make sure an username, password and email have been entered and such. > > Any decent authentication system will do this for you, for free. >

[Rails] Re: Sign up (create account, create user)

2010-10-20 Thread Leonel *.*
> What should be getting validated? Make sure an username, password and email have been entered and such. About the form, I was using form_tag and then realized the form is not connected to any class. How can I connect the form to two different classes? For example: company_name field to Account

[Rails] Re: Sign up (create account, create user)

2010-10-20 Thread Leonel *.*
>>> So? You still need models. >> You mean, a model that references other models? > Huh? You seemed to be saying you didn't have User and Account models. Yes, I do. According to Colin, the validation will be taken from User and Account models. > Why do you need both User and Account? From the

[Rails] Re: Sign up (create account, create user)

2010-10-20 Thread Leonel *.*
> Are you using an authentication library such as Authlogic for this? If > not, I highly recommend doing so. Nope, I'm using a digest sha2 password with salt. I'll take a look at Authlogic. > So? You still need models. You mean, a model that references other models? > Do you have a question he

[Rails] Sign up (create account, create user)

2010-10-20 Thread Leonel *.*
The application I'm creating works like this: There is an account (a company) Users belong to the Account (company) So when somebody wants to sign up and create an account, it should create an account, then create a user. username(User) password(Users) company(Account) So I created a Signup cont

  1   2   >