Displaying 20 results from an estimated 1000 matches similar to: "How to trim a string?"
2006 Apr 06
2
using select() to relate tables
I''m sorry to be asking trivial questions, but I''m new to RoR and am
hooked :), so I''m very impatient to get things up and running.
given two related tables, "pcs" and "venues" (venues have many PC''s and
each PC belongs to one venue only) I can use a select() to present venue
names in the "new PC" form along with other PC details to
2006 Jun 16
3
ActiveRecord, using sql functions for some attributes
Hi.
I need to use functions INET_ATON, INET_NTOA for IP address retrieving.
Is it possible to make this transparently (without custom SQL for
saving, updating and retrieving)?
2006 Jul 05
3
splitting a story with double-spaced para''s
Quick question - if i want to separate a long string of text, separated
by single carriage returns, into an array of paragraphs, I can use the
following code:
paragraphs = article.content.split("\n")
The "\n" means a carriage return, as far as I can tell.
If I wanted to take text, that had been written using the more common
double carriage returns, into an array of
2006 Apr 06
6
select method
The documentation states as an example:
select("post", "person_id", Person.find_all.collect {|p| [ p.name, p.id ] },
{ :include_blank => true }) could become:
<select name="post[person_id]">
<option></option>
<option value="1" selected="selected">David</option>
<option
2006 Aug 18
4
Button on view
Hi,
I have a page containing 3 views (2 are partials). One of the partials
needs to have a button that will clear a table called "messages" in the
database.
I can put a button like this "<%= button_to "Clear Messages", :action =>
''clear_messages'' %>" and have the controller do "Message.delete_all".
But the problem is that the
2006 Apr 05
25
How to avoid bunch of <% %> ??
Hello, I would like to know is there is a way to avoid poluting the
views with tons of <% %> ?
Like this
<%= start_form_tag() %>
<%= text_field_tag(''category[title]'', category.title, {:size => 20,
:maxlength => 128}) %>
<% if not category.parent_id.nil? %>
<%= select("category", "parent_id",
Category.find(:all,
2006 Jul 03
13
Eager loading ActiveRecord objects
I have a complex graph of ActiveRecord entities that I want to load with
one big honkin'' join query to avoid ripple loading. It''s for a report.
However :include doesn''t get me all the way there because I want to load
parents of parents (or children of children). I don''t mind doing the
SQL by hand but I''m not quite sure what to do to get the result
2006 Jul 05
1
time.next_week bug?
i ran into an error today when dealing with the method next_week and
daylight savings time...
>> Time.local( 2006,10,23 ).next_week
=> Tue Oct 24 00:00:00 EDT 2006
Any one know if this is a know issue or should a ticket be created for this
issue?
thanks for the help
mark
--
Mark Van Holstyn
mvette13@gmail.com
http://lotswholetime.com
-------------- next part --------------
An HTML
2006 Apr 13
7
Whats the best way to achieve this?
employees HABTM projects, projects HABTM employees.
I am doing a permissions page for a selected project. I know that I can
get all of the employees in the system (@employee.find(:all)) or get all
the employees for the selected project.
What i''m trying to do is get a list of all the employees in the system
and have a check box that states if they are associated with the
current
2006 Jun 24
4
setting attribute in constructor, .NEW works but not .CREATE
I have table "decks" with three fields: "id", "created_at" and "cards"
which is a 264-character string field. I have modified the model with a
constructor, as follows:
class Deck < ActiveRecord::Base
attr_reader :cards
def initialize
@cards = "12345"
end
end
If I call Deck.new from my controller, I get no errors and an object
with the
2006 Mar 28
2
In_place_editor_field throws error ...
I receive the following error:
Called id for nil, which would mistakenly be 4 -- if you really wanted
the id of nil, use object_id
when trying to use the in_place_editor_field tag:
<% for employee in @employees %>
<%= in_place_editor_field :employee, employee.fname %>
<% end %>
My model is called Employee and is being populated from a controller
method employees_list:
2006 Apr 11
26
Firefox won''t let me send ''&'' with AJAX!
Hi everyone,
I''ve encountered a HUGE problem, which may not be RoR-oriented, but
there might be a workaround somehow.
See, at this moment, I''m unable to send AJAX requests back and forth
when the information contains an ampersand (''&''). In essence, request is
never completed. The odd thing is that it only happens with Firefox (IE
and Opera works fine).
2006 Jul 03
2
Still struggling with data flow ...
Hello,
The following view:
<%= start_form_tag %>
Enter term to find
<p>
<%= text_field_tag :name, params[:name] %>
</p>
<%= link_to "Find", { :action => ''find_term''} %>
<%= end_form_tag %>
does not appear to pass back the value of :name to the action:
def find_term
term =
2006 Jul 05
2
splitting a paragraph into words and spaces
I''m using this:
<% words = article.content.split(/ /) %>
<%= words[0..20] %>
to (ostensibly) split a paragraph into component words, with spaces in
between, then print to html only the first 20 items, words and spaces. I
got this (split(/ /)) from the online pickaxe book at
http://rubycentral.com/book/ref_c_string.html#String.split . The problem
is, the resulting array
2006 Apr 07
2
ActiveRecord find all based on array -- need ids from array
Does anyone know if it is possible to perform an ActiveRecord find by
passing in an array? I would like to be able to do the following:
MyModel.find(:all, :conditions => ["user_id in (?)", users])
The problem I run into is that the returned SQL contains the to_s()
output of the User object, not the ids of those users. Is it possible
to change this behavior? I attempted to
2006 Apr 03
7
Javascript helpers not updating table row in IE6
Trying to replace a table row with an id using both RJS templates and
normal link_to_remote :update. Neither work in IE6, fine in FF etc.
If I use the same code but target a div with an ID it works. This is
tricky as I have a table with edit buttons, when the button is pressed
that row gets updated with a partial containing a form for update. I
need this to work as II don''t fancy
2006 Feb 08
3
ungenerate / remove scaffold command?
I have seen this somewhere and can''t find it now. Is there an ungenerate
or remove command for the scaffold generator. It would be easier than
removing all the files by hand.
I have tried ./script/ungenerate but no luck.
Thanks
--
Posted via http://www.ruby-forum.com/.
2006 Apr 06
2
rails 1.1 - console broken
Have upgraded to rails 1.1 and now ruby script/console does not work.
Throws an error:
c:\work\development\rails\application1>ruby script/console
Loading development environment.
c:/tools/ruby/lib/ruby/1.8/irb/init.rb:151:in `parse_opts'': undefined
method `up
case'' for nil:NilClass (NoMethodError)
from c:/tools/ruby/lib/ruby/1.8/irb/init.rb:19:in `setup''
2006 Aug 17
2
RJS - slower than normal RHTML?
I know that isn''t supposed to be the case, and it usually isn''t, but
today, I''ve run across a situation where rendering the same partial
through RJS is taking about 5 times longer than rendering the partial in
the RHTML.
I have in my main RHTML
<tbody id="account_transactions">
<%= render :partial =>
2006 Feb 19
3
accounts and subdomains
With reference to a previous
post:http://www.ruby-forum.com/topic/55201#new
I would like my app to function as follows:
A new user signs up for my application, his username is "andy". When
andy now logs in to the application the url is redirected to :
http://andy.myapplication.com
Questions:
Is this possible to develop on a windows box with webrick?
Do I need anything special like