similar to: Agile book deltas

Displaying 20 results from an estimated 1000 matches similar to: "Agile book deltas"

2006 Jun 20
1
ActiveRecord saving madness?
Hello, First of all, I love RoR. I am studying it, and I am finally "getting there". However, I do have a bit of a problem with ActiveRecord''s saving behaviour. Imagine to have Orders (id, name) {has_one:invoice} and Invoices (id, order_id) {belongs_to :order} . If you type: invoice = Invoice.new(...whatever...) an_order.invoice = invoice if invoice fails to save, you
2006 Jul 12
5
2 subdirectories 1 controller?
Hi, I''d like to create the following setup with RoR: www.mywebsite.com/subdir1/order/create www.mywebsite.com/subdir2/order/create I''d like both urls to call the same action in the same controller. How can I do this? I know this may be complicated, but I''m prepared to go a long way. Shimon -------------- next part -------------- An HTML attachment was scrubbed...
2006 Jul 29
2
Finding sum
# Get a list of product ids from a form, then # sum the total price product_list = params[:product_ids] total = Product.find(product_list).sum(&:price) I understand the first list line and part of the second line, but what does the & symbol mean? TIA.
2008 Jan 21
7
undefined method error
Hello everyone, I am following the Practical Rails: Social Networking sites book. In chapter 7 photo gallery I am getting a NoMethodError in Pages#show Showing layouts/_menu.rhtml where line #12 raised: undefined method `new_entry_path'' for #<ActionView::Base:0x52fa56c> Extracted source (around line #12): 9: <% if is_logged_in? %> 10:
2009 Apr 29
7
problem with nil.user
Hi all, I''ve put new code into my app so that an administrator will have extra privileges (administer users, edit pages). The error is: ''Couldn''t find User without an ID'' So the app is looking for a logged in user when the homepage is accessed. Heres my code: site/index view: <% if is_logged_in? and logged_in_user.has_role?(''Moderator'')
2009 Jun 05
6
rails 2.3.2
Hi all, I am using rails v.2.3.2 and if I put following line to my ApplicationController: include LoginSystem and I moved my login_system.rb to lib folder: module LoginSystem protected def is_logged_in? @logged_in_user = User.find(session[:user]) if session[:user] end def logged_in_user return @logged_in_user if is_logged_in? end def logged_in_user=(user) if
2006 Jul 27
2
setting initial text field values in a form
Hi, I am trying to create a basic form in which I want one of the fields initialized before displaying it. My code (in a view) is as follows: <% if ( session[:user_id] != nil ) then logged_in_user = User.find(session[:user_id]) end %> <% form_for :suggestion do |form| %> <label for="suggestion_title">Topic:</label><br/> <%=
2006 Jun 06
5
Functional tests and protected actions
Hello! I have certain methods in my Application Controller, that I need to access. Namely ApplicationController#logged_in_user The problem is, that when I try to access it, I get: NoMethodError: protected method `logged_in_user'' called for #<AdminController> Any ideas how I can circumvent that? Or are functional tests really not suited for any kind of logins and session work?
2006 Mar 02
8
User Authentication
I''m trying to create a simple authentication system but am failing miserably. I''m (sort of) following the "Logging In" chapter of the Agile book. Ideally, any access to http://example.com/publish (and any of its subdirectories) should redirect to http:/example.com/publish/login when there is no valid session user_id. Code so far:
2006 Dec 01
3
Sessions in Layered Dispatching
Can you use sessions in layered dispatching? I used them in direct dispatching without any problems, but switching to layered throws an error (saying session doesn''t exist). Sorry if this is a double post, Google Groups isn''t posting my message for some reason. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this
2009 Feb 25
3
Secure but elegant destruction method
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 => :destroy then any user could potentially log in and start issuing: /users/1/destroy /users/2/destroy .
2006 Mar 16
4
Handling/Catching Exceptions
Hello! I was wondering, sometimes I raise an exception in my Rails apps, e.g.: raise SecurityError unless @post.user == logged_in_user Now: is there any way to catch that SecurityError exception somewhere and render a custom template? E.g., I want to render ''app/views/content/security_error.rhtml'' Does anyone know how to do this? Thanks a bunch, Rob
2009 May 20
3
ffmpeg + mp3 convert
Hi all, I am using paperclip plugin to upload mp3''s. Before I save the mp3 I would like to convert it to a smaller size. I am using ffmpeg library and in my Track model I am calling: before_save :convert_mp3 def convert_mp3 system("ffmpeg -i #{mp3.to_file.path} -vn -ar 44100 -ac 2 -ab 64 -f mp3 #{mp3.to_file.path}") end But this fails. Am I missing something?
2006 Jul 27
1
no method??
Whenever i type what the book says which is... xml.order_list(:for_product => @product.title) do for o in @orders xml.order do xml.name(o.name) xml.email(o.email) end end end it gives me this error that says... NoMethodError in Info#who_bought You have a nil object when you didn''t expect it! The error occured while evaluating nil.title Extracted source (around line
2006 Dec 07
17
compress and max upload size?
I am using mongrel_cluster with mod_proxy_balancer and would like to enable compression (assuming it improves throughtput) and limit file size upload. I configured mod_deflate and LimitRequestSize in Apache, but in my trials looks like the proxied calls bypass those directives (the conf goes below). Is there a way to get this? -- fxn # Adapt this .example locally, as usual. # # To be
2006 Apr 07
2
Access instance variables from model?
Can I make my model methods aware of the context (preferably instance variables) where they are run, without having to pass them arguments? The app in question should be time zone aware, so something like user.events[0].starts_in should check against @logged_in_user.now rather than Time.now. I could send the user as an argument (user.events[0].starts_in(:timezoned => @logged_in_user)),
2006 May 24
7
migrations and SQLite
I read in the instructions of Tracks that "upgrading via the rake migrate command is quite a bit more tricky currently with SQLite and SQLite3". Is there any gotcha regarding migrations and SQLite3? -- fxn
2013 Nov 06
6
Feature: make capitalization optional in *humanize*
According to the documentation<http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-humanize> of ActiveSupport::Inflector: *humanize*(lower_case_and_underscored_word) Capitalizes the first word and turns underscores into spaces and strips a trailing “_id”, if any. * Example: humanize("employee_salary") # => "Employee salary"* I would
2006 Jul 17
5
quantic phenomena in migrations
I have an application with 15 migrations under version control. In a Mac and and in a Windows, a rake migrate from scratch runs them all just fine. But in a different Windows machine rake migrate stops after migration 3 for no apparent reason. --trace seems normal. No error is reported. Both Windows are XP SP2. They all have the same svn revision and Rails-related software, database is
2010 Feb 25
9
uninitialized constant UsersController::User
i just created an application to list the primary details of userbut it is showing an error lik this "uninitialized constant UsersController::User" this is my controlller class UsersController < ApplicationController puts"hiiiiiiiii" def index puts"hiiiiiiiii" @users = User.find(:all) puts @users respond_to do |format| format.html # index.html.erb