[Rails] Juggernaut plugin - push data to client without use of publish method?

2011-10-15 Thread John Merlino
Hey all, Juggernaut is a plugin that provides realtime connection between your servers and client browsers. You can literally push data to clients using your web application. The instructions say to instantiate the Juggernaut object and subscribe to the channel: jug = new Juggernaut({ host:

[Rails] Re: partials and render_to_string

2011-09-19 Thread John Merlino
thanks for response On Sep 19, 4:26 am, Frederick Cheung frederick.che...@gmail.com wrote: On Sep 18, 7:40 pm, 7stud -- li...@ruby-forum.com wrote: 2) What exactly is the point of render_to_string? Why can't we just use render? Or do we need to use render_to_string in order to use the

[Rails] partials and render_to_string

2011-09-18 Thread John Merlino
Hey all, This is my understanding of html and browsers. On the server, html is plain text. When the browser sends request to server to fetch a document, if the file is not already in html format, perhaps instead in an rb file, ruby or whatever the server-side language of choice converts the file

[Rails] Re: partials and render_to_string

2011-09-18 Thread John Merlino
this was incredible response, everything was explained so clearly. On Sep 18, 2:40 pm, 7stud -- li...@ruby-forum.com wrote: John Merlino wrote in post #1022569: Hey all, This is my understanding of html and browsers. On the server, html is plain text. When the browser sends request

[Rails] Re: question about a where condition

2011-09-12 Thread John Merlino
thanks for responses -- 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-talk+unsubscr...@googlegroups.com. For

[Rails] question about a where condition

2011-09-11 Thread John Merlino
Hey all, This example of working code: @a = @b.where(:a_group_id.ne = nil).collect { |b| b.a_group } doesn't make too much sense to me. For one, I am not sure what that ne is doing there. Is this a postgresql thing? Second, it looks like we are collecting active record objects where the

[Rails] Re: question about a where condition

2011-09-11 Thread John Merlino
thanks for response. What you said explained a lot. Now I have never seen rails code written like that. Would it have been better to do this: @b.map(:a_group).compact.uniq On Sep 11, 11:32 am, Robert Walker li...@ruby-forum.com wrote: John Merlino wrote in post #1021280: Hey all

[Rails] Re: with_options and Rails 3

2011-09-05 Thread John Merlino
bump The reason why player path wasnt working was because it required an instance of player: player_path(@player). But I am still stuck as to why dashboard_sidebar_path isn't working when the route clearly shows up when running rake routes. On Sep 4, 4:20 pm, John Merlino stoici...@aol.com wrote

[Rails] Re: same html elements rendering twice on page

2011-09-05 Thread John Merlino
thanks for response, and the explanation of capture(). When I removed the concat from the helper, the title stopped rendering twice. I thought the concat was used to concatenate the two blocks of html, but after reading documentation it appears it's to render haml without using =. On Sep 5, 8:19 

[Rails] Re: with_options and Rails 3

2011-09-04 Thread John Merlino
in the scope, so I dont know why the error. thanks for response On Aug 31, 5:42 pm, John Merlino li...@ruby-forum.com wrote: I havent tested it yet but thanks for response -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby

[Rails] Re: with_options and Rails 3

2011-09-04 Thread John Merlino
, 2011 at 3:42 PM, John Merlino stoici...@aol.com wrote: So I tried using the :as option for the named route so I could have dashboard_sidebar_path helpers.  scope :path = '/dashboard', :controller = :dashboard do      match '/sidebar.:format' = :sidebar, :as = 'dashboard_sidebar'       match

[Rails] same html elements rendering twice on page

2011-09-04 Thread John Merlino
hey all, My index.html.haml: - wrap do - page_title Teams List View application_helper.rb: def page_title(title) content_tag :h1, title end def wrap(block) concat(content_tag(:div, capture(block), :class = generic_header)) end I load in browser and get: div

[Rails] Re: RestClient send method?

2011-08-31 Thread John Merlino
thanks for responses -- 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

[Rails] with_options and Rails 3

2011-08-31 Thread John Merlino
Hey all, Rails guide doesnt cover with_options in Rails 3: http://guides.rubyonrails.org/routing.html The book The Rails 3 Way makes no reference to with_options except for one page briefly. And I cannot find a decent tutorial to cover what I am trying to do. I have this: map.with_options

[Rails] Re: with_options and Rails 3

2011-08-31 Thread John Merlino
I tried this: scope :path = '/dashboard', :name_prefix = dashboard_, :path_prefix = dashboard, :controller = :dashboard do match '/sidebar.:format' = :sidebar match '/charts.:format' = :charts match '/action_items.:format' = :action_items match '/performance.:format' =

[Rails] Re: with_options and Rails 3

2011-08-31 Thread John Merlino
I tried a named route and I get this: undefined local variable or method `dashboard_sidebar_path' any idea? -- 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] Re: with_options and Rails 3

2011-08-31 Thread John Merlino
I havent tested it yet but thanks for response -- 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

[Rails] call method dynamically on active record association

2011-08-12 Thread John Merlino
Hey all, I have this in view: - if site_action_enabled?(:site_flag_enabled, Site) And I have this in application controller: def site_action_enabled?(operation, resource) if resource.is_a?(Class) resource == Site return current_user.site.call operation else

[Rails] Re: capture, blocks, and + operator

2011-08-03 Thread John Merlino
My understanding of the + operator is as follows. The + operator works differently with arrays than it does with scalar values. With arrays, when taking two arrays as operands, it returns an array containing everything in the two oeprand arrays. In essence, + operator performs addition on

[Rails] capture, blocks, and + operator

2011-07-25 Thread John Merlino
Hey all, Let's say we have this: #view = section Contact do - field_list :class = contacts-view do |v| = v.item Contact Type, @contact.contact_type #helper def section(*args, block) label = String === args.first ? args.first : String === args.second ? args.second : nil klass =

[Rails] invoke a class method on an array of objects?

2011-07-19 Thread John Merlino
Hey all, The Subject line may be a bad question, whether it's possible to invoke a class method on an array of objects. But look at the code below, and unless I am misunderstanding, that's what appears to be going on, and yes the code does work: class Dog def total_caught Cat.counters(:dog

[Rails] when iterating tables with ActiveRecord::Base.connection, how do you check if a string is equal to the current table iteration?

2011-07-11 Thread John Merlino
Hey all, This here is not working: task(:load_selected = :load_config) do IgnoreTables = %w('students') begin ActiveRecord::Base.establish_connection ActiveRecord::Base.connection.tables.each do |table| if IgnoreTables.include? table puts Its

[Rails] undefined method for 1:Fixnum

2011-06-28 Thread John Merlino
Hi all, What I am trying to do: 1) Search for books at a specific school 2) Iterate through each book and find all its related subbooks where the book state is of a specific type 3) Return an array of those subbooks for each book 4) Since the array will have subarrays of the subbooks, flatten

[Rails] Re: undefined method for 1:Fixnum

2011-06-28 Thread John Merlino
, only instances of the class. Is this the problem and how would I address it? Thanks for response On Jun 28, 1:34 pm, Michael Pavling pavl...@gmail.com wrote: On 28 June 2011 18:10, John Merlino stoici...@aol.com wrote:    available_books = books.each.map do |book|      book.subbooks.where

[Rails] Re: undefined method for 1:Fixnum

2011-06-28 Thread John Merlino
hmmm, this returns true as well: logger.info is true? #{available_books.flatten.first.respond_to? ('sequence')} On Jun 28, 3:22 pm, John Merlino stoici...@aol.com wrote: Thanks for response. I checked with logger and it is indeed an array: logger.info Is array

[Rails] Re: undefined method for 1:Fixnum

2011-06-28 Thread John Merlino
actually you are right. my intention was to get the object with the smallest sequence number, not return the sequence number itself. The ruby documentation says this: Returns the object in enum with the minimum value. for min. Hence, I thought it would return the object. I suspect the error is

[Rails] insert value of primary key into another field before record is saved

2011-06-26 Thread John Merlino
Hey all, I created a seed task: def books! books = Book.where(:type_id = Type.find_by_name('Fiction')).order('id') books.each do |book| @books = 4.times.map do |i| subbook! #{book.book_num}-#{i}.to_s, :book_state = BookState[:available].id, :book = book end end

[Rails] instantiating object and passing a new array into the block

2011-06-24 Thread John Merlino
Hey all, Out of curiousity, all in Rails grabs all the records and converts them into an array. Map then iterates through the returned array, returning a new array. So why even use map here? And then the array gets passed as local variable bt. And we instantiate object and assign the bt array as

[Rails] method calls and blocks and calling proc

2011-05-20 Thread John Merlino
Hey all, I have a question about this line of code: within #main-menu do find(h6, :text = menu).click if menu click_link link end def within(selector, blk) new_blk = proc do begin scope_selectors.push(selector) blk.call ensure scope_selectors.pop end

[Rails] Re: unexpected results when extending methods to class Class and class Object

2011-05-17 Thread John Merlino
I still dont think I am fully clear on the Class class role. For example: ruby-1.8.7-p330 :010 class Class ruby-1.8.7-p330 :011? def is_a? ruby-1.8.7-p330 :012? puts 'a' ruby-1.8.7-p330 :013? end ruby-1.8.7-p330 :014? end = nil ruby-1.8.7-p330 :015 A.is_a? a = nil ruby-1.8.7-p330

[Rails] Re: how instance_eval on Object class creating class methods and not instance methods?

2011-05-17 Thread John Merlino
Let me see if I fully understand this. This: Object.instance_eval def a puts 'a' end end is equivalent to this: class Object def self.a puts 'a' end end Basically, instance_eval invoked on Object creates a new class method for the Object class (or for class Class? and if it is

[Rails] Re: unexpected results when extending methods to class Class and class Object

2011-05-16 Thread John Merlino
but instances of Object aren't i.e. Object.kind_of? Class is the wrong test - Object.new.kind_of?(Class) (or in your specific example, Peach.new.kind_of?(Class)) is the relevant one. Fred Thanks for response -- Posted via http://www.ruby-forum.com/. -- You received this message because

[Rails] how instance_eval on Object class creating class methods and not instance methods?

2011-05-16 Thread John Merlino
Hey all, I am a little confused about a tutorial I read. Here's an example below taken from the tutorial: Object.instance_eval do def has_attribute( *attrs ) attrs.each do | attr | self.class_eval %Q{ def #{attr}=(val)

[Rails] loading of views and controller actions

2011-05-15 Thread John Merlino
Hey all, Let's say you want a customized route. You want to create a helper for it (e.g. password_recovery_root_path) and a url path (e.g. passwords/recovery) that when it is invoked, points the user to the passwords controller's get_email method. So you would do this: map.resources

[Rails] Re: what is proc doing here?

2011-05-13 Thread John Merlino
validates_presence_of is a method call, :unless is the key part of the hash part of the parameters to validates_presence_of, and the proc (equivalent to Proc.new) part is sent as the value to key :unless. Hope that was short enough. Thanks for response. I see what it's doing now. -- Posted

[Rails] unexpected results when extending methods to class Class and class Object

2011-05-13 Thread John Merlino
Hey all, There's a core Class class and core Object class in Ruby library: http://www.ruby-doc.org/core/classes/Object.html http://www.ruby-doc.org/core/classes/Class.html First, let's resolve the simple distinction between an Object and Class as envisioned by Smalltalk but within the Ruby

[Rails] what is proc doing here?

2011-05-12 Thread John Merlino
Hey all, This line of code I am having trouble understanding what it's doing: validates_presence_of :email, :unless = proc { |this| this.validation_context == :create_user } Basically, there is a code block that floats adjacent to a method. The method is called and returns a value. That yielded

[Rails] self.included like a constructor method that gets called when a module is included in a class?

2011-05-09 Thread John Merlino
Hey all, Let's say you have a controller class and you include a module: class ApplicationController ActionController::Base include AuthenticationSystem def default_page case when cu.group_is?(:a) then a_path when cu.group_is?(:b) then b_path when cu.group_is?(:c)

[Rails] Re: self.included like a constructor method that gets called when a module is included in a class?

2011-05-09 Thread John Merlino
The point of this is to call helper_method :current_user. You can look up what helper_method does in the rails docs. Fred ok so basically this allows you to use current_user in your views. thanks for response -- Posted via http://www.ruby-forum.com/. -- You received this message because

[Rails] RestClient send method?

2011-05-05 Thread John Merlino
Hey all, I see this line of code: RestClient.send(verb, url, parameters) Basically there's two rails application that communicate with each other. RestClient is a rails gem. Here we send the get http verb and a url string comprising of the other application base url and append a query string to

[Rails] Re: Re: Given I know where a method is defined, I want to know where its called (at runtime)

2011-05-05 Thread John Merlino
The argument to caller is optional. You might also want to install ruby-debug and add a breakpoint. Fred Yeah kind of like breakpoint in C++. Thanks for response. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby

[Rails] is not allowed as an instance variable name error

2011-05-04 Thread John Merlino
Hey all, I get error like this: ActionView::TemplateError (`@content_for_details_view_builder__-626960428' is not allowed as an instance variable name) in app/views/shared/_details_view.haml: searchlogic (2.4.27) lib/searchlogic/rails_helpers.rb:75:in `fields_for' searchlogic (2.4.27)

[Rails] Given I know where a method is defined, I want to know where its called (at runtime)

2011-05-04 Thread John Merlino
Hey all, application completely breaks down in production mode. I followed the execution file by file line by line and yet I cannot figure out where an instance variable is being generated from. But I have a suspicion. This method right here: # neeeded becasuse of a rails bug def to_s

[Rails] Re: Given I know where a method is defined, I want to know where its called (at runtime)

2011-05-04 Thread John Merlino
Philip Hallstrom wrote in post #996721: On May 4, 2011, at 6:39 PM, John Merlino wrote: I think it's cause of problem. I also noticed that the developer left a comment above it. Problem is it's part of a class that gets yielded into a ruby block and there's a number of partials that get

[Rails] Re: questions about cookies when bridging together two rails apps

2011-04-29 Thread John Merlino
Frederick Cheung wrote in post #995797: On Apr 29, 3:04am, John Merlino li...@ruby-forum.com wrote: Settings.session_token_domain} 1) I look in Session class and there is no create! class method. Yet it works and doesn't throw an exception. With so little context it is hard to say

[Rails] Re: what does :new = {:start = :get} mean in routes?

2011-04-28 Thread John Merlino
Obviously map.resources :sessions, :member = {:validate = :get}, :new = {:start = :get}, :only = %w(create new) creates new route for you like the one you have in new method redirect_to start_new_session_path and return if current_user Thanks for response. I do notice this: form_tag

[Rails] questions about cookies when bridging together two rails apps

2011-04-28 Thread John Merlino
Hey all, I am looking through this example Rails app where a user session is stored in cookie so user signs up in one rails app and navigates to another while still being signed in as unique user. I come across this line of code where I don't understand where some of these methods are coming

[Rails] what does :new = {:start = :get} mean in routes?

2011-04-26 Thread John Merlino
Hey all, I'm looking at this route below: map.resources :sessions, :member = {:validate = :get}, :new = {:start = :get}, :only = %w(create new) It's clear the sessions has the 7 restful routes but each member of a collection of records can also be influenced by the validate method. Then I come

[Rails] Re: what does :new = {:start = :get} mean in routes?

2011-04-26 Thread John Merlino
M Daubs wrote in post #995201: I believe you only have two restful routes (create and new) because of the line: :only = %w(create new) And the start action is defined as an alternative new action here, probably because the original author wanted a GET instead of POST (/

[Rails] perform a check and then call super class when user creates new session

2011-04-25 Thread John Merlino
Hey all, I'm using devise plugin for rails. When the user creates a new session, in addition to devise authenticating the user, I want to check if the user is enabled by checking the value of the enabled (a boolean) field in the database. If the value is 0, I want to alert user that they haven't

[Rails] Re: perform a check and then call super class when user creates new session

2011-04-25 Thread John Merlino
While I almost got the behavior I want, there's a problem: def create @user = User.authenticate(params[:user]) if !@user.enabled render shared_navigation/confirmation elsif request.post? #just using else instead of elsif request.post? gives same unwanted behavior

[Rails] undefined method error because I am not understanding Rails initializers

2011-04-25 Thread John Merlino
Hey all, In app/builders, I have a file called table_builder.rb. In the constructor method of my TableBuilder class, I call an instance method called assign_attributes which takes a hash and converts the key/value pairs into instance methods. The assign_attributes method is declared in the

[Rails] Re: undefined method error because I am not understanding Rails initializers

2011-04-25 Thread John Merlino
I restarted the server and it appears to have worked. -- 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] do a select from another table within a model

2011-04-19 Thread John Merlino
Hey all, This right here: scope :index_blog, { :select = blog_posts.*, :joins = INNER JOIN categories ON category.id = blog_posts.category_id, :conditions =blog_posts.enabled = 1 } returns this: Mysql2::Error: Not unique table/alias: 'categories': SELECT blog_posts.* FROM

[Rails] Re: do a select from another table within a model

2011-04-19 Thread John Merlino
Actually, all i wanted to do initially was this: def filter_scoper(scoper) logger.info The current class is #{self.class} #CategoriesController if params.has_key? :filter send :#{params[:filter]}_filter_scoper, scoper elsif self.class.respond_to?(:blog_filter_scoper)

[Rails] Re: do a select from another table within a model

2011-04-19 Thread John Merlino
ok I must never forget that in haml it works like this: - @resources.each do |r| %h1= r.title %p= r.body not this: = @resources.each do |r| %h1- r.title %p- r.body Otherwise, you will get an ActiveRecord array as an object. -- Posted via http://www.ruby-forum.com/. -- You received

[Rails] Re: do a select from another table within a model

2011-04-19 Thread John Merlino
It would appear to me that your immediate problem is the line of code I pointed out above. Yeah I got it now. Basically: if self.class.respond_to? will only respond to class methods of the class, not instance methods and since attr_accessor returns instance methods, that if will return

[Rails] best practices for debugging errors on production mode on server

2011-04-18 Thread John Merlino
Hey all, I think I need some help with best practices for debugging. So I am familiar with logger.info e.g. The variable is #{@variable}. This helps when I want to inspect the value of a variable on my local machine. However, it doesn't get output to the production log so when the site runs on

[Rails] TypeError (Cannot visit Category):

2011-04-18 Thread John Merlino
Hey all, this order_by method right here is throwing an exception: @resource_model.order_by(@order_field) The exception is TypeError (Cannot visit Category): I think it's returning this: #ActiveRecord::Relation:0x01038701f0 I have no clue why. It's supposed to be returning a string like

[Rails] Re: hash vs methods

2011-04-14 Thread John Merlino
Thanks for responses. So it's possible to call include? on a method? dom_class.include?(sortable) -- 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] Re: Re: hash vs methods

2011-04-14 Thread John Merlino
Phil Crissman wrote in post #992790: On Thu, Apr 14, 2011 at 10:09 AM, John Merlino li...@ruby-forum.com wrote: Thanks for responses. So it's possible to call include? on a method? dom_class.include?(sortable) Well, you aren't calling include? on the method, per se... you're calling

[Rails] hash vs methods

2011-04-13 Thread John Merlino
Hey all, Hash vs methods may seem like a silly question, but in certain situations I don't understand why you would use a method over a hash. For example, take a look at this method: #this is defined in a class called core.rb def assign_attributes(attributes) attributes.each_pair { |k,v|

[Rails] Re: trying to seed data from seeds.rb within a class structure

2011-04-05 Thread John Merlino
Kendall Gifford wrote in post #991124: Have you tried adding: StaticDataGenerator.new.posts! to the end of your file? Thanks for response. yes, that worked. That makes sense that you need to call a method in client code for it to do anything. I do have one unexpected result. This method

[Rails] Re: trying to seed data from seeds.rb within a class structure

2011-04-05 Thread John Merlino
def posts! Title.each_with_index do |t, i| post! t, Body[i], @current_user.id end end each_for_index is very helpful. Thanks a lot for responses. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby

[Rails] {:class=pi stuff} is not a symbol

2011-04-01 Thread John Merlino
Hey all, I'm building a html helper. My view looks like this: = item_view title, @post.title, :class = 'stuff' My helper looks like this: def format_item_data(data) case data when Class then '' when School then school(data) else data.to_s

[Rails] Re: why does my method return an error if argument is not a number?

2011-03-30 Thread John Merlino
Thanks for all the responses. My understanding it's breaking when I try to pass nothing as an argument to that function because you can't pass an undefined variable as an argument. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google

[Rails] route helpers are not working

2011-03-30 Thread John Merlino
Hey all, I find this in ruby guide: resources :photos do collection do get 'search' end end It will also create the search_photos_url and search_photos_path route helpers. So I try to implement: #routes resources :core do collection do get 'coreim' get 'corer' end

[Rails] Re: route helpers are not working

2011-03-30 Thread John Merlino
Thanks for response, it outputs this: coreim_core_index GET/core /coreim(.:format) {:action=coreim, :controller=core} corer_core_index GET/core/corer(.:format) {:action=corer, :controller=core} So I would expect this to work: coreim_core_path corer_core_path

[Rails] Re: route helpers are not working

2011-03-30 Thread John Merlino
$rake routes coreim_cores GET/cores/coreim(.:format) {:action=coreim, :controller=cores} cores GET/cores(.:format) {:action=index, :controller=cores} ah, thanks for response. I didnt see this message on my last response. -- Posted via

[Rails] why does my method return an error if argument is not a number?

2011-03-28 Thread John Merlino
Hey all, I get the following error message: ActionView::TemplateError (class or module required for rescue clause) in app/vie$ app/helpers/format_helper.rb:116:in `divide_numbers' Basically I have a field in database called Student Fails and I populate fields with data. Sometimes the value can

[Rails] Re: wrong constant name user error

2011-03-25 Thread John Merlino
Frederick Cheung wrote in post #988949: On Mar 23, 8:52pm, John Merlino li...@ruby-forum.com wrote: params[:controller].singularize.constantize.responds_to(:viewable) Presumably this is the line throwing the error. If params[:controller] is users then you'll be calling constantize

[Rails] using a paginate method to display the second group of 25 records on page 2

2011-03-25 Thread John Merlino
Hey all, I'm trying to fully understand what this method in Ruby does. Basically it passes a collection of records from the database (using the Rails find method) into the argument list as a local variable called resources. It assigns the local variable to an instance variable called

[Rails] Re: using a paginate method to display the second group of 25 records on page 2

2011-03-25 Thread John Merlino
Suppose 90 records... ((90-1)/30).to_i + 1 = 3, 3 full pages It's just some math hijinks to make sure any partial page isn't missed in the page count. Thanks that was very helpful. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the

[Rails] Re: Re: wrong constant name user error

2011-03-25 Thread John Merlino
Frederick Cheung wrote in post #989266: On 25 Mar 2011, at 16:47, John Merlino li...@ruby-forum.com wrote: Frederick Cheung wrote in post #988949: On Mar 23, 8:52pm, John Merlino li...@ruby-forum.com wrote: if params[:controller].singularize.capitalize.constantize.method_defined

[Rails] wrong constant name user error

2011-03-23 Thread John Merlino
Hey all, I have a table helper. Basically I want only certain tables to have a view link for each record. Im not sure the best way to achieve this but the way I can up with is to check if the model contains a certain method such as viewable and if it does, then you create the link in a table

[Rails] table helper not rendering table

2011-03-18 Thread John Merlino
Hey all, layout_helper.rb: def table(collection, header_names, fields, class_name) return false unless collection.any? table_str = table_str += table id=\ + class_name + \ class=\ + class_name + \\n table_str += \tthead\n table_str += \t\ttr\n header_names.each

[Rails] Re: table helper not rendering table

2011-03-18 Thread John Merlino
Frederick Cheung wrote in post #988214: On Mar 18, 7:06pm, John Merlino li...@ruby-forum.com wrote: table_str += \t\ttr\n fields.each do |name| What the above does is render a big string of what I am wanting to display as html markup. If I add puts(table_str) to the helper method

[Rails] Re: table helper not rendering table

2011-03-18 Thread John Merlino
You're seeing the html because rails automatically escape html for you these days. You can call html_safe on a string to mark it as not needing escaping (although that shifts the responsibility of checking that things are indeed safe to you ) Fred Thanks it worked! -- Posted via

[Rails] Re: invalid json response when using devise plugin

2011-03-10 Thread John Merlino
Has anyone gotten devise to work at all with any kind of ajax? -- 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

[Rails] invalid json response when using devise plugin

2011-03-09 Thread John Merlino
Hey all, I am using devise. While the data successfully updates to database, it still reports back as an error, and the below error function is executed: var options = { type: 'POST', url: /user, dataType: 'json', data: $('#dialog-form

[Rails] Re: Devise and Ajax

2011-03-08 Thread John Merlino
I actually now hard code the create method I want to invoke: var options = { type: 'POST', url: users/create, dataType: 'json', data: $('#sign-in form:first').serialize(),

[Rails] Re: Devise and Ajax

2011-03-08 Thread John Merlino
I modified the routes to point to controller. But now I get this: Started POST /users/create for 127.0.0.1 at 2011-03-08 14:21:21 -0500 Processing by UsersController#create as JSON SQL (177.7ms) BEGIN SQL (1.6ms) ROLLBACK Rendered text template (0.0ms) Completed 422 Unprocessable Entity

[Rails] Re: Devise and Ajax

2011-03-08 Thread John Merlino
Resolved. I had to post to user model, which triggers registration 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

[Rails] Devise and Ajax

2011-03-06 Thread John Merlino
Hey all, I installed the devise plugin and I'm sure it's fully installed. I have a popup where user creates an account, including email, password, and password confirmation. When they click submit, I use jquery's .ajax method: $.ajax({ url: $('#dialog-form

[Rails] Re: Re: Re: accessing the field of a model that belongs to another model using dot notation

2011-03-01 Thread John Merlino
Also you have not said what happens if you include the test checking for no blog_images. Colin I think I realized what the problem was. There were four records in the blog_posts table. At the time of the post, I only had one record in blog_images table that linked to first record of

[Rails] Re: accessing the field of a model that belongs to another model using dot notation

2011-02-25 Thread John Merlino
Thanks for replies. This: post.blog_images.first.image_file_name outputs undefined method `image_file_name' for nil:NilClass I think that means I called a method on a class that it cannot find? I have already established has_many belongs_to between blog_images and posts table. This doesn't

[Rails] User successfully authenticates but is not logged in as current_user in session?

2011-02-25 Thread John Merlino
Hey all, When someone is on my login page, I have this: % form_for :user, :url = { :action = login } do |f| % %= f.label(:user_email, User Email)% %= f.text_field(:email) %br/ %= f.label(:user_password, User Password)% %= f.password_field(:password) %br/ %= f.submit(Login) % %=

[Rails] Re: User successfully authenticates but is not logged in as current_user in session?

2011-02-25 Thread John Merlino
and this is checking session[:user_id]. Furthermore one appears to be storing an actual user object whereas your other piece of code seems to be expecting there to be just an id. Fred You're right! Thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you

[Rails] Re: Re: accessing the field of a model that belongs to another model using dot notation

2011-02-25 Thread John Merlino
That means that in your chain of method calls, the thing before image_file_name is nil. So there is no first record in the blog_images collection... are you sure you have some associated images? Yes, in my database I have blog_images table with a foreign key of blog_post_id of 1. In my

[Rails] Re: undefined method current_user issue

2011-02-23 Thread John Merlino
At the top of your controller, you'll want to add helper_method :current_user Thanks for response, but I place this in application controller: helper_method :current_user private def require_login unless logged_in? flash[:error] = You must be logged in to access this section

[Rails] accessing the field of a model that belongs to another model using dot notation

2011-02-23 Thread John Merlino
Hey all, with this below (a post has many blog_images and blog_image belongs to post): % @posts.each do |post| % div class=FeatureItem a href=img src=/images/%= post.blog_images.image_file_name % width=220 height=174 alt= style=top: 27px; left: 13px; /Click Here/a div

[Rails] Re: Using route helper returns undefined method

2011-02-22 Thread John Merlino
Check rake routes. Is the route there? Yeah, I had to use: cocoreim_cocore_index_path -- 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] undefined method current_user issue

2011-02-22 Thread John Merlino
Hey all, I have this in my plugins directory: 1: % if current_user current_user.admin? % 2: div class=blogAdminLinks 3: ul class=blogList 4: li class=blogListFirst%= link_to 'New Blog Post', new_blog_post_path %/li As you can see,it references current_user So I define current_user

[Rails] How to access controller located as part of another application in plugins directory

2011-02-21 Thread John Merlino
Hey all, I installed blogkit as a rails plugin. It installed in the vendor directory as an entire application. called blog_kit. This application has a controller called blog_posts_controller. However, when I route to blog_posts in my application: resources :blog_posts do resources

[Rails] Using route helper returns undefined method

2011-02-21 Thread John Merlino
Hey all, I have this in routes: resources :cocore do collection do get :cocoreim end end I have this in ccore controller: class CoController ApplicationController def index end def cocoreim render 'cocoreim' end end In indx.html.erb of cocore view directory, I

[Rails] Re: fast_xs.c:169: error: ‘struct RArray’ has no member named ‘ptr’

2011-02-17 Thread John Merlino
I ended up just commenting it out. -- 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

[Rails] Re: rvm install 1.8.7 prompts There has been an error while running make. Halting the installation.

2011-02-14 Thread John Merlino
Frederick Cheung wrote in post #981180: On Feb 11, 3:36pm, John Merlino li...@ruby-forum.com wrote: readline.c: In function username_completion_proc_call: readline.c:730: error: username_completion_function undeclared (first use in this function) readline.c:730: error: (Each undeclared

[Rails] Re: rvm install 1.8.7 prompts There has been an error while running make. Halting the installation.

2011-02-14 Thread John Merlino
Frederick Cheung wrote in post #981653: On Feb 14, 7:51pm, John Merlino li...@ruby-forum.com wrote: Frederick Cheung wrote in post #981180: However, I try to create rails 2 project and got an uninviting error: MacBook-Pro:~ jmerlino$ rails _2.3.5_ myproject /Users/jmerlino/.rvm/rubies/ruby

[Rails] fast_xs.c:169: error: ‘struct RArray’ has no member named ‘ptr’

2011-02-14 Thread John Merlino
Hey all, I tried to do bundle install in my Rails 3 project and got this error: /Users/jmerlino/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb checking for stdio.h... yes creating Makefile make gcc -I. -I/Users/jmerlino/.rvm/rubies/ruby-1.9.2-p136/include/ruby-1.9.1/x86_64-darwin10.2.0

[Rails] Re: rvm install 1.8.7 prompts There has been an error while running make. Halting the installation.

2011-02-11 Thread John Merlino
Frederick Cheung wrote in post #980922: Error running 'make ', please read /Users/jmerlino/.rvm/log/ruby-1.8.7-p330/make.log So, what was in it? Fred Towards bottom it says this: readline.c: In function ‘username_completion_proc_call’: readline.c:730: error: ‘username_completion_function’

<    1   2   3   4   >