Displaying 20 results from an estimated 110 matches similar to: "Dynamically updating list"
2006 Apr 04
3
Keeping javascript in the <head>
Given that Rails has built in ways to do almost everything else :) , is
there a way to keep view specific javascripts inside the head tag of a
layout without having to include that javascript on every page?
--
Marlon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060404/65e9bb6d/attachment.html
2006 May 01
2
Find by time?
I''m trying to find events created after an initial date. I''m sure it''s
something obvious, but I''m not sure why this isn''t working:
def self.find_recent
find(:all, :conditions=>"created_at > #{Time.local(2006, 4, 27, 22, 0, 0)}")
end
Time for more caffeine for me...
2009 Jul 23
11
Problem with named_scope
Here are my scopes:
default_scope :order => ''posted_on DESC'', :conditions => { :status =>
''visible'' }
named_scope :positive, :conditions => { :rating => ''positive'', :status
=> ''visible'' }
named_scope :neutral, :conditions => { :rating => ''neutral'', :status
=>
2007 Apr 21
3
attachment_fu thumbnails
howdy!
I had the problem that attachment_fu didn''t make a thumbnail, but
everything else worked. I read this post
http://www.ruby-forum.com/topic/104213 and added a parent_id column. now
I get the following error when I trie to add a photo:
undefined method `find_or_initialize_by_thumbnail_and_parent_id'' for
Photo:Class
my code is:
class Photo < ActiveRecord::Base
2006 Apr 02
7
RANT: belongs_to -> refers_to
Every once in a while, I pipe up and whine that "belongs_to" should really
be ''refers_to" [http://dev.rubyonrails.org/ticket/2130]. It''s time again.
I''ve got a bunch of stuff going onto eBay, so, like any good engineer, I
don''t just post it manually: I design a Rails-based inventory database that
creates a semantically-correct XHTML/CSS auction
2006 Apr 05
3
Issuing an ajax request to a different web server?
Is it possible to have an Ajax request go to a different server than
the one that originally rendered the web page? I am attempting this,
but the ajax server never gets the request.
For example, inside a form:
<%= submit_to_remote(''add_lead'',''Add Lead(s)'',
:url =>
"http://123.456.789.0:3000/users/add_lead",
2005 Dec 16
0
Quick ORM question
Quick question on this query:
@item.entries = Entry.find_recent(@td.id, 10) || []
My development log file shows that rails makes 2 calls to database! Is
rails ORM not smart enough to know to not load the lvalue of assignment thus
causing another expensive db call? Below are the stubbed models and a log
snip.
class Entry < ActiveRecord::Base
belongs_to :tracking_definition
def
2006 May 25
13
.NET developer trying to understand some Rails basics
Hi All,
I''ve been a ASP.NET developer for the last few years and consider it to
be a pretty productive environment to work with. However, the
object-relational mapping (ActiveRecord) and simplicity of the Rails
framework and Ruby in general really appeals to me. .NET currently
doesn''t have something like Rails'' ORM - atleast not out-of-the-box.
Here''s my
2007 Aug 18
12
Test::Unit to RSpec
So I''ve just started working on a rails project which currently has
something like 7500 LOC. All of the tests are written in Test::Unit,
although the test coverage is pretty poor: rcov says that 25% of the
code is covered, while rake stats shows the code to test ratio as
1:0.1 (800 lines of test code).
I guess I''m wondering what would generally be advisable here. Is it
2006 Aug 18
1
Fragment Caching
Hello.
I wouldn''t mind getting some feedback about the use of fragment
caching. I''ve got a series of relatively expensive database queries
with their respective partials cached and everything is working fine.
The problem is that do get this to work I''ve had to move the database
queries from the controller into the view layer so as to avoid them
being called if the
2006 Dec 20
4
undefined method `fullname' for #<User:0x357e380>, BUT works on first view?
Hi all,
Please excuse the long post, but I wanted to make sure you have all the
information....
I have a NewsModel that looks like this:
class News < ActiveRecord::Base
belongs_to :user
validates_associated :user
validates_length_of :title, :description, :minimum => 5, :allow_nil
=> false
acts_as_commentable
acts_as_taggable
def self.find_recent
News.find(:all,
2006 Jan 23
16
Adding form fields (extending a form) on the fly
Hello,
I just can''t seem to find a way to extend a form dynamically in ROR.
Say I am writing a recipe website. There is one form to enter the
recipe. There is room for N number of ingredients (let''s say a text
field for each ingredient name and selection list for the amount). What
if the user wants to add more than N ingredients as he types them in?
how do I do this without
2006 Jan 20
1
Update HTML Element with Ajax
I have following files.
list.rhtml
-----------------------
<ul id="items">
<%= render(:partial => ''item'', :collection => @items) %>
</ul>
_item.rhtml
------------------------
<li id="<%= item.id %>" >
<%= item.name %>
<%= item.body %>
</li>
edit.rjs
------------------------
page.replace_html
2006 Feb 14
2
Inline list editing with RJS: best practices
I wanted to get the community opinion on the best way to use partials and
inline list (<li>) editing.
I have a very common scenario where a list is rendered:
--- index.rhtml ---
<ul>
<%= render :partial => ''item'', @collection => @items %>
</ul>
--- _item.rhtml (simplified) ---
<li id="item_<%= item.id %>">
<div
2005 Oct 15
1
Partials and controllers
Newbie question:
From a _form.rhtml file I have:
<%= render(:partial => ''item'', :collection => @items) %>
In _item.rhtml I have:
<% @tullt = h(item.body) %>
<%= @itemdb = Group.find(:all,
:conditions => "id = ''#{@tullt}''").map {|u| [u.name] }
%>
<%= @tullt %
I think it would be better to
2006 Mar 08
4
ajax with tables
There may be an easy solution, but I just can''t seem to get this to work...
I''m using tables for part of my site, as they contain a lot of rows and
columns full of financial data, so just working with div''s and dd''s... etc,
won''t do.
My table structure is pretty simple, as follows:
=================
<table id="items">
<tr>
2006 Mar 15
4
[NQ] How to set an initial FK for a new item of something?
Hi all,
running into a little problem here. I''ve a list of things
with a "New thing" link beneath it. When you click that link,
obviously, a new thing shall be created. Now, that works pretty
fine for things that don''t have foreign keys, but for things that
do it crashes, since there is not yet a thing.other_thing.name
available.
I suspect you can somewhere in
2006 Aug 03
5
DRYing up the view
Hello everyone!
I have generic views for CRUD operations
For example I render(''shared/list'') from controller
shared/list.rhtml
...
<% for item in @list %>
<tr class="<%= cycle ''list-line-odd'', ''list-line-even'' %>">
<%= render :partial => ''item'', :locals => { :item => item } %>
2006 Jan 06
2
How do I reference eagerly loaded Models in the View?
[I hope the repost isnt'' "minded". Following the advice of another
thread I''ve changed the subject to a question. If I haven''t included
important info, please ask. My database is being unduly killed. Jodi]
Cheers on-the-Rails-ers,
Before I start, I''ve read the ActiveRecord docs on eager loading, but
for the life of me, I can''t seem to get
2008 Apr 23
0
Passing a hidden field to insert_html
I''m trying to pass a hidden field (item_property) to the add_link
helper function but when I do it the process threads start eating up
memory and my computer freezes.
[code=helper.rb]
def add_link(name)
link_to_function name do |page|
page.insert_html :bottom,:partial, :partial => ''item'', :object
=> Item.new(:item_property => "Some text")