[Rails] Re: Redirecting to another controller, with a POST method

2009-03-20 Thread Vahagn Hayrapetyan
Fernando Perez wrote: > Hi, > > You cannot redirect with a POST method, so you'll have to find a trick > to circumvent that issue. Right! Cheers, Vahagn -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are s

[Rails] Re: Redirecting to another controller, with a POST method

2009-03-19 Thread Vahagn Hayrapetyan
Hi MaD,- yep, I can see your line of reasoning. It appears that it is probably not very RESTful to check for POST, so that can be dropped altogether. It seems conceptually wrong that you need to ensure something is POST'ed, but then it only works from a view and not a controller. If something

[Rails] Re: Redirecting to another controller, with a POST method

2009-03-19 Thread Vahagn Hayrapetyan
Cheers MaD,- thanks for the reply. Here's what I'll do: if @user == logged_in_user if @user.destroy flash[:notice] = "Your account has been deleted" reset_session #the meat of the logout method else flash[:error] = "There was a problem deleting your account." end That may seem li

[Rails] Redirecting to another controller, with a POST method

2009-03-18 Thread Vahagn Hayrapetyan
Hi. How do I call a method in controller B from controller A and ensure it is treated as a POST method? I have a method in my account_controller: #CONTROLLER: ACCOUNT def logout if request.post? #isn't reached when redirected to from users_controller: reset_session flash[:notice] =

[Rails] Re: Secure but elegant destruction method

2009-02-26 Thread Vahagn Hayrapetyan
Yeah - good point Jeff. / V. Jeff Emminger wrote: > I don't see anything wrong with this. I'd only resort to a filter if > it was going to be used by multiple actions. > > On Feb 25, 11:02�am, Vahagn Hayrapetyan htt

[Rails] Re: Secure but elegant destruction method

2009-02-25 Thread Vahagn Hayrapetyan
Sorry, the code should have been: def destroy @user = User.find(params[:id]) if @user == logged_in_user or logged_in_user.has_role?('administrator') if @user.destroy flash[:notice] = "User deleted" else flash[:error] = "There was a problem deleting this user.

[Rails] Secure but elegant destruction method

2009-02-25 Thread Vahagn Hayrapetyan
Hi,- I am looking for a clean and secure way for an ActiveRecord instance to delete itself. Say I have a User model in my app. Then the destructive action would be /users/user_id/destroy. If this action is not secured by a filter like: (*) before_filter :check_administrator_role, :only => :destr

[Rails] Geocoding recipe: locations not showing on Google Maps

2009-01-22 Thread Vahagn Hayrapetyan
Hi, can someone helpe me out with a Google Maps issue: I've incorporated one of the recipes in Advanced Rails Recipes book (the GeoCoding one). Although everything is done exactly as in the recipe, the locations do not show up on Google Maps. (The geocoding part of the recipe works - the Geokit h

[Rails] rcov not detecting existing and valid test cases

2009-01-06 Thread Vahagn Hayrapetyan
Hello,- got a question regarding strange behavior by rcov. I have a gyms_controller.rb with the usual group of CRUD methods. Each one of them is being tested in the gyms_controller_test.rb: $ ruby test/functional/gyms_controller_test.rb Loaded suite test/functional/gyms_controller_test Started

[Rails] Re: Testing a POST request with correct param

2009-01-02 Thread Vahagn Hayrapetyan
... and I'm looking forward to the day I'm able to give back, as well. / V. Patrick Doyle wrote: > On Fri, Jan 2, 2009 at 2:53 PM, Vahagn Hayrapetyan < > rails-mailing-l...@andreas-s.net> wrote: > >>puts "OPTIONS: " + options[:user] #method und

[Rails] Re: Testing a POST request with correct param

2009-01-02 Thread Vahagn Hayrapetyan
Hi guys and thanks a lot. post 'account/forgot', :user => {:email => 'j...@example.com'} is the deal. Patrick, if you could figure this out by putting print statements in your controller you're a better Rails coder than me :-) Did you mean: def forgot puts "OPTIONS: " + options[:user] #m

[Rails] Testing a POST request with correct param

2009-01-01 Thread Vahagn Hayrapetyan
Hi,- I'm wondering how to test POSTing something to an action from a form. I am testing an action named "forgot" in my account_controller.rb. It takes an email address as a parameter and does things based on whether a user with that email address exists: def forgot if request.post? use

[Rails] Re: Installing from Git with current Rails version

2008-11-28 Thread Vahagn Hayrapetyan
s it looks like information duplication. / Vahagn Frederick Cheung wrote: > On 28 Nov 2008, at 13:52, Vahagn Hayrapetyan wrote: > >> >> Sorry, but something seems to be wrong here. I've added the path, so >> now >> I have: >> >> $ cat .bash_login

[Rails] Re: Installing from Git with current Rails version

2008-11-28 Thread Vahagn Hayrapetyan
Issue resolved! One must configure Git BEFORE sudo make install: http://www.freshblurbs.com/installing-git-os-x-3-minutes / Vahagn -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

[Rails] Re: Installing from Git with current Rails version

2008-11-28 Thread Vahagn Hayrapetyan
ceive-pack git-upload-pack But $ which git just gives a blank new line! I've tried restarting the Mac, but nothing. Really mystified here, any help help appreciated! / Vahagn Vahagn Hayrapetyan wrote: > Thanks a lot! Will give it a try. > > All the best, Vahagn > > Peter De Be

[Rails] Re: Installing from Git with current Rails version

2008-11-28 Thread Vahagn Hayrapetyan
Thanks a lot! Will give it a try. All the best, Vahagn Peter De Berdt wrote: > On 28 Nov 2008, at 14:07, Vahagn Hayrapetyan wrote: > >> I had actually installed Git using this package: >> http://code.google.com/p/git-osx-installer/ >> >> but maybe it is not th

[Rails] Re: Installing from Git with current Rails version

2008-11-28 Thread Vahagn Hayrapetyan
Hi Peter,- I had actually installed Git using this package: http://code.google.com/p/git-osx-installer/ but maybe it is not the newest version? Best regards, Vahagn Peter De Berdt wrote: > On 28 Nov 2008, at 13:38, Vahagn Hayrapetyan wrote: > >> removing: /Users/vahagn/myapp/ve

[Rails] Interpreting a "no route matches" message

2008-11-28 Thread Vahagn Hayrapetyan
Hi, - I am trying to make the Highslide image viewer to work with with a Rails app and I have done everything (image tag markup, right files in right directories etc) according to their tutorial. However when I load the page with a highslide-marked-up image I get following error messages in the l

[Rails] Installing from Git with current Rails version

2008-11-28 Thread Vahagn Hayrapetyan
Hi,- I'm trying without success to install a plugin from Git using the command: $ script/plugin install http://github.com/pyrat/wee_lightbox.git What I get is: removing: /Users/vahagn/myapp/vendor/plugins/wee_lightbox/.git sh: git: command not found Then I checked this page: http://github.c

[Rails] Re: Routing to a new action of a nested resource

2008-11-25 Thread Vahagn Hayrapetyan
ed and the most important thing is the proper pluralization of the controllers. All the best, Vahagn Nick Hoffman wrote: > On Nov 4, 8:08�am, Vahagn Hayrapetyan <[EMAIL PROTECTED] > s.net> wrote: >> has one house. >> >> /V. > > Hi Vahagn. Resources don'

[Rails] Passing object parameters to urls in tests

2008-11-16 Thread Vahagn Hayrapetyan
I am wondering how to pass parameters to route declarations. I have an app where one project belongs to a user. In one of my integration tests, I want to check that the template being rendered is the one where the "logged in user" can register a project: get new_user_project_path(:user) #does not

[Rails] Re: Routing to a new action of a nested resource

2008-11-04 Thread Vahagn Hayrapetyan
Issue solved! users.resource :houses, :controller => 'user_house' instead of: users.resource :house, :controller => 'user_house' end Apparently the resources are always plural, regardless that a user only has one house. /V. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~

[Rails] Re: Routing to a new action of a nested resource

2008-11-04 Thread Vahagn Hayrapetyan
PS! Correct url is http://localhost:3000/users/21/house/new :-) -- 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 ema

[Rails] Routing to a new action of a nested resource

2008-11-04 Thread Vahagn Hayrapetyan
Hi, can anyone help with a routing problem for nested resources: My models are User (has_one :house) and House (belongs_to :user). I have a houses_controller and a user_house_controller. house_controller is for the admin to perform CRUD on houses; so users' CRUD must go through the user_house_co

[Rails] Re: (Newbie) routing question

2008-10-29 Thread Vahagn Hayrapetyan
that you don't have a user set for that photo > and it can't generate the URL without knowing the id of the user. > > On Oct 28, 5:48�am, Vahagn Hayrapetyan <[EMAIL PROTECTED] -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You

[Rails] (Newbie) routing question

2008-10-28 Thread Vahagn Hayrapetyan
Hi, I have a question about routing and nested resources. I have an app with Photos that belong to Users via a many2one relationship. The URL: http://localhost:3000/photos lists all photos (from all users). Clicking on a random photo from this listing should send one to f ex: http://localhost:3

[Rails] Re: Functional test behaving oddly in a manually working model

2008-10-27 Thread Vahagn Hayrapetyan
examining the test log (great tip, sure to become a habit!) All the best, Vahagn Frederick Cheung wrote: > On 27 Oct 2008, at 10:43, Vahagn Hayrapetyan wrote: > >> >> Hi Fred,- >> >> login_as works in all other tests! And I actually test it by the puts >> statem

[Rails] Re: Functional test behaving oddly in a manually working model

2008-10-27 Thread Vahagn Hayrapetyan
email: [EMAIL PROTECTED] hashed_password: #very long hash created_at: <%= 1.days.ago.to_s(:db) %> / Vahagn Frederick Cheung wrote: > On Oct 27, 10:33�am, Vahagn Hayrapetyan <[EMAIL PROTECTED] > s.net> wrote: >> are supposed to. Here's a method from NewslettersContro

[Rails] Re: Functional test behaving oddly in a manually working model

2008-10-27 Thread Vahagn Hayrapetyan
> expected but was <1>. / Vahagn Vahagn Hayrapetyan wrote: > Hello all,- > > wondering if you can help me with a weird testing problem. I have a > Newsletter model that has been developed and tested in a previous > version (older branch) of my current project. Under tha

[Rails] Functional test behaving oddly in a manually working model

2008-10-27 Thread Vahagn Hayrapetyan
Hello all,- wondering if you can help me with a weird testing problem. I have a Newsletter model that has been developed and tested in a previous version (older branch) of my current project. Under that old project, all tests run perfectly with no failures. Moreover, in the current project Newsle

[Rails] Re: Observer not picking state change in user

2008-09-28 Thread Vahagn Hayrapetyan
Oh well. I just love those programming mistakes that make one appear like a total n00b because they are so basic one doesn't even stop to think about their possibility of occurring. Thanks Fred, it's working now :-) / Vahagn -- Posted via http://www.ruby-forum.com/. --~--~-~--~~-

[Rails] Observer not picking state change in user

2008-09-28 Thread Vahagn Hayrapetyan
Hello,- does anyone have a good idea of how to trace a fault in the following: I have a User model (user.rb) with these methods: def create_reset_code code = User.get_random_string(10) #working class method self.password_reset_code = code self.save(false) @reset = true #Noti

[Rails] Re: "Nil object": really?

2008-09-22 Thread Vahagn Hayrapetyan
Hi Bharat,- there's hardly a Rails book that is not near the top of my Amazon wish list - so you're right on ;-) Cheers, Vahagn Bharat Ruparel wrote: > Glad to be of help. I am no expert on ActiveRecord Mailer, but when I > run into problems like this, I turn to: > 1. Agile Web Development b

[Rails] Re: "Nil object": really?

2008-09-19 Thread Vahagn Hayrapetyan
Thanks Bharat, that was excellent advice. It turns out the real trouble is being caused by this line: Notifier.deliver_newsletter(user, newsletter) Now, the stack trace looks like this: NameError in Newsletters#sendmails Showing notifier/newsletter.text.plain.rhtml where line #3 raised: und

[Rails] Re: "Nil object": really?

2008-09-18 Thread Vahagn Hayrapetyan
Hi Phlip, I appreciate the feedback. Firstly, I renamed users to all_users and the error is still there; therefore, no aliasing occurs. Secondly, I've tried as you wrote: (all_users || (p 'still nil!'; []).each Notifier.deliver_newsletter(user, newsletter) end but that gives a synta

[Rails] PS Re: "Nil object": really?

2008-09-18 Thread Vahagn Hayrapetyan
And here's the output of raise users.to_yaml: --- - !ruby/object:User attributes: last_login_at: updated_at: 2008-09-01 12:47:57 hashed_password: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918 profile: Site Administrator username: Admin id: "1" ena

[Rails] Re: "Nil object": really?

2008-09-18 Thread Vahagn Hayrapetyan
Frederick Cheung wrote: > On Sep 18, 9:41�am, Vahagn Hayrapetyan <[EMAIL PROTECTED] > s.net> wrote: >> Hello,- > >> Yet after the first iteration, I get an error / crash. >> >> I have tried to change users to @users, with the exact same result. >> De

[Rails] "Nil object": really?

2008-09-18 Thread Vahagn Hayrapetyan
Hello,- I am developing a rails app with this method in it: # PUT /newsletters/1;send def sendmails newsletter = Newsletter.find_by_id_and_sent(params[:id], false) users = User.find(:all) raise users.to_yaml #debugger users.each do |user| #evaluates to nil.each - debug