[Rails] Re: Creating formatted PDFs

2012-05-22 Thread Ar Chron
Marc C. wrote in post #1061690:
> Except one part: I don't know how to
> render correctly the HTML in the PDF file.
>
> Currently I use the Prawn library to create the PDF's.

I use Prawn to generate pdf's, Nokogiri to parse the html portion and 
created an element_to_pdf method to walk the html, looking for tags to 
respond to, constructing the pdf.text statements to execute based on the 
tag encountered.

Something like:

doc = Nokogiri::HTML(text)
children = doc.children[1].children[0].children
# doc / html / body / elements
children.each do |child|
  element_to_pdf pdf, child
end

or something like that...  code isn't at hand

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Calling destroy in a has_many_and_belongs_to and has_many :through

2012-05-22 Thread Ar Chron
Msan Msan wrote in post #1061478:
> I've noticed that if I use associations with has_many_and_belongs_to
> and i call a destroy method on an object of the association, the
> record in the join table is automatically deleted.
> If I use has_many :though, for example:
>
> Category
> has_many :categorizations
> has_many :products, :through => :categorizations
>
> I have to put explicity
>
> has_many :categorization, :dependent => :destroy
>
> otherwise the association isn't deleted.
> Why?

A HABTM B (to me) infers that the join table AB serves no purpose other 
than to link As and Bs. Without a specific A, the AB record has no 
meaning.  So the HABTM specification lets Rails make the assumption that 
when A is deleted, the AB related to that A can be deleted as well.

A has_many B
A has_many C, through B
implies (also to me) that joining through the intermediary table B is an 
artifact of the relationships between As, Bs, and Cs, and the entity 
modeled in B has value independent of its relationship between A and C. 
Like

Project
has_many :scenarios
has_many :unittests, :through => :scenarios

When a Project is deleted, I don't want all those Scenarios deleted...

Unittest
has_many :testings, :dependent => :destroy
has_many :testresults, :through => :testings

When a unittest is deleted, I delete all the testings (and testresults) 
since test results or testing instances aren't much use without the 
requirements (the unittest).

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Multiple references of Country table in single client table

2012-04-27 Thread Ar Chron
akshar jamgaonkar wrote in post #1058608:
> Hi I am new to ruby on rails , i am trying to develop a form client
> form having multiple refrences to country... i.e while adding a client
> i can add two contact persons each have a country associated with
> them. However with scaffolding iam unable to refer country
> twicecould anyone of you shed some light as to where iam going
> wrong or what could be the rite way

Sooo, sounds like the basic scaffold functionality won't work.  So 
you'll have to take control and write some code of your own.

My own two cents...  scaffolding is good for education, and a look at 
how Rails is designed to work, but it's just the basics.  Never done 
Rails before?  Scaffold up a model with some attributes, then go look at 
that generated code.  Figure out how all the pieces and parts work 
together.  Then start writing your own code.

I use scaffolding for proof of concept all the time, but the scaffolded 
code doesn't survive very long at all.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Routes - Search url parser

2011-05-09 Thread Ar Chron
danimashu wrote in post #997411:
> I would prefer to have a url like that:
> - example.com/ford/red
>

But then what happens with:

 - example.com/pink/cadillac  ?

I'd be careful of investing any particular logic behind your urls for 
dealing with arguments.  Do all your users catagorize things the same 
way you do?  Probably not.

One person I work with definitely does not prioritize attributes in the 
order I do, and she is invaluable because of it.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Php to Ruby compilation software

2011-05-04 Thread Ar Chron
Femto Zheng wrote in post #996564:
> Hello all, because most of php's application is feature rich than
> rails's existing offer,
> like say, crm solutions,  sugarcrm,
> I know rails have similar offering,( fat_free_crm), but unfornately,
> this is really far
> from the feature sugarcrm offers,
> sugarcrm has been developed since 2004, all 7 years, and has been
> funded
> $2 million in venture capital, I just don't think anyone could port
> that easily in
> a short time frame.
>
> for hand-rewritten the php's application, well, that's at least
> theoretically,
> I've done that before, that's quite time-consuming and error-prone.
>

Possibly time-consuming, yes.  Error-prone depends on the tests that are 
in place...  But the generated Ruby you show above would cause most 
Rubyists to flee.

If the entire application is translated with that amount of syntactic 
noise, what is your maintenance path?  Edit the original php 
application, then translate again?!?

I'm not knocking your accomplishment (Lord knows I've written code that 
writes some awfully ugly code), but there a wide gap between 
syntactic/semantic correctness and syntactic/semantic "elegance", and I 
think the "elegance" attribute is what has drawn many people to Ruby.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Migration error

2011-04-28 Thread Ar Chron
amritpal p. wrote in post #995532:
>   Then ran "rake
> db:migrate",it created a new columns in table products with name
> "price" ,but i didnt change the view(didnt create a filed with name
> "price")

Migrations don't do that (you can create migrations to do all sorts of 
things, not necessarily related to new fields for a view).

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Routing Error

2011-04-28 Thread Ar Chron
amritpal p. wrote in post #995520:

> On Apr 28, 3:25am, Colin Law  wrote:
>>
>> >  root :to => "say#hello"
>>
>> So you think that the above line, which says route '/' to say#hello'
>> is going to route /say/goodbye somewhere?

>   No it will not route to /say/goodbye,but it will route to /say/
> hello which has a link to /say/goodbye method.

Umm... no it won't, as evidenced by your own statement:

> When i click on Goodbye link given in hello.html.erb file it says
> "No route matches "/say/goodbye".

Take a look at your log file and see what your Rails application is 
receiving when you click the "Goodbye" link in the browser. Review your 
routes.rb file.  If you run a

rake routes > routes.lst

then look at the routes.lst file, you'll know exactly what routes you 
have available in your application. Next, re-read the Rails guide on 
routing.

I hesitate to just say "type this code in here and it will work" because 
that doesn't lead to learning or understanding.  Directing you to look 
at your log file to see what your application is receiving, seeing what 
Rails has as routes for your application, and pointing to the correct 
reference for reading may.

It's the old "give a man a fish..." strategy.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: NoMethodError in Book

2011-04-26 Thread Ar Chron
amritpal p. wrote in post #995096:
> Yes i have tried scafffolding.But i want to generate a form
> without scaffold.i want to manualy create a controller,view and model
> for it.please help to do it.
>
> Thanks

Yes, fair enough.  But use the scaffolded elements as the prototype for 
your manual creations...  If you have scaffolded something, then the 
"right way" (or at least the way that follows the Rails conventions most 
cleanly) is there in front of you.

Suppose you want a book model.
1. You'll need a books_controller.  By conventions:
- the index method in the controller retrieves all the books into a 
variable named @books.
- the show method retrieves a single existing book stored into a 
variable named @book according to an id received in the params
- the new method created a new book, named @book via a simple @book = 
Book.new
- the edit method also retrieves a single existing book stored into a 
variable named @book according to an id received in the params
- the create method receives a book definition via params and creates a 
new @book instance from the values contained in the params, then 
attempts to persist that object in the DB.
- the update method retrieves an existing book via a find using the id 
received in the params, then updates that books attributes with those 
also received in the params.
- destroy finds a book according to the id received in the params, and, 
well, deletes it.

Each of these controller methods, be default, will have its results 
rendered in a view named according to the method that the view supports.
- index method renders its output via the index.html.erb
- new and edit render via new.html.erb and edit.html.erb, each of which 
uses a partial named _form.html.erb (and yes, that underscore at the 
beginning of the filename is important).

If you are creating your own, then don't forget to update the routes.rb 
when you add a new model and controller, or action to an existing 
model/controller.

All of this is readily apparent from a study of a scaffolded solution, 
and a little reading.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: NoMethodError in Book

2011-04-26 Thread Ar Chron
amritpal p. wrote in post #995086:
> Stuff...

You seem to be lacking some fundamental "organizational" knowledge as it 
pertains to a Rails application.

What I found very instructive way back when was to scaffold a basic 
application and see what Rails created, and how it was organized.  Then 
I fiddled with that scaffolded application, one change at a time.

If you have an existing application, you can just add a scaffolded 
model, controller, and views via:

rails g scaffold person first_name:string last_name:string

(doesn't have to be person, could be anything, just give it a model name 
and some attributes with types).

Then look at the controller, model, and views that are created.  Most 
enlightening.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: how to update data

2011-04-18 Thread Ar Chron
News Aanad wrote in post #993479:
> hi, I have json string in json request.
> i want to update the database using that string.
> how can i do that?
> There would be a multipal object in this string.
>
> sample string is:
>
> 
[{"product":{"amt":300,"created_at":"2011-03-28T05:46:52Z","id":1,"prodnm":"maruti","qty":1,"rate":12,"updated_at":"2011-03-28T05:46:52Z"}},{"product":{"amt":2000,"created_at":"2011-04-18T09:02:45Z","id":2,"prodnm":"lux","qty":2,"rate":12,"updated_at":"2011-04-18T09:02:45Z"}}]
>
> Can anybody help me???

Deserialize the string into the separate product objects (JSON.parse 
from http://flori.github.com/json/ perhaps?), then use the normal object 
methods to perists the data I think.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: How to generate a form in rails 2.3.5

2011-04-18 Thread Ar Chron
amritpal p. wrote in post #993489:
>But i didnt explain in which
> file it should be written?
>
> Thanks

Well, perhaps you would benefit from seeing a scaffolded response. At an 
OS prompt, type in:

ruby script/generate scaffold person first_name:string last_name:string

run the resulting migration, then take some time to look at the 
controller, model, and views created for a person / people.

That might give you some insight to how Rails works by default.  Then 
you could answer your own question I think.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Can join tables be polymorphic?

2011-04-07 Thread Ar Chron
Andy Tolle wrote in post #991031:
> For example:
> Currently I have:
> functions < functions_competencies < competencies
> exams  < exam_competencies  < competencies
>
> I'd like to dry up "functions_competencies" and "exam_competencies" by
> using a polymorphic association, by let's say 'attached_competencies':
>
> functions  < attached_competencies < competencies
> exams  < attached_competencies < competencies
> evaluations < attached_competencies < competencies
> ...
>
> Note that these are join tables.
>
> Is this possible?
IIRC, this is based on the has_many_polymorphs plugin

class appl
  has_many :appllinks
  has_many :projects,
   :through => :appllinks,
   :source => :project,
   :conditions =>? "appllinks.appllinkable_type = 'Project'"
  has_many :scenarios,
   :through => :appllinks,
   :source => :scenario,
   :conditions =>? "appllinks.appllinkable_type = 'Scenario'"
  has_many :unittests,
   :through => :appllinks,
   :source => :unittest,
   :conditions =>? "appllinks.appllinkable_type = 'Unittest'"

class appllink
  belongs_to :appl
  belongs_to :appllinkable, :polymorphic => true
  belongs_to :project,
 :class_name => 'Project',
 :foreign_key => 'appllinkable_id'
  belongs_to :scenario,
 :class_name => 'Scenario',
 :foreign_key => 'appllinkable_id'
  belongs_to :unittest,
 :class_name => 'Unittest',
 :foreign_key => 'appllinkable_id'

class project
  has_many :appllinks, :as => :applinkable, :dependent => :destroy
  has_many :appls, :through => :appllinks

classes scenario and unittest are just like project

YMMV

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Need help in changing data in production.

2011-04-07 Thread Ar Chron
Marco Antonio Filho wrote in post #991464:
> Now comes the problem. I need to deploy these
> changes
> in the production servers. I already have the script to update the
> changes,
> but I don't know what is the conventional place to put it. Not in the
> migrations, I know.

Why not a migration?  Seems like the correct place for a one-shot 
change.

Create the new table.
Migrate the data.
Once and done.

I've done this numerous times on a project as the design evolves (create 
new table(s), reorganize existing data), and the migrations provide the 
audit trail of the actions.

Just make sure your down action undoes everything appropriately, but 
that's what your dev environment is for, isn't it?

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: [JOBS] Help build some product in London

2011-03-25 Thread Ar Chron
Nick Marsh wrote in post #989203:
> That means no clients or anything

Oh but you DO have clients, you just don't know them yet.

Involve elements of your projected user base(s) now, and you might find 
a much higher adoption rate later...

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



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

2011-03-25 Thread Ar Chron
John Merlino wrote in post #989291:
>
> ((@all_resources.size - 1) / @limit).to_i + 1
>
> What does the size method do and why add one at the end?
>

Suppose 100 records, with a page size of 30

num_pages = ((100-1)/30)
num_pages = 99/30
num_pages = 3.3
num_pages = 3 (to_i)
num_pages = 4

3 full pages of 30 records, and 1 page with 9 records

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.

The slice(offset,limit) is the elegant part. Start at the "offset", and 
return "limit" items.

On page 2, the offset is 1*25, skipping the records that would be 
returned on page 1, and returns the next page's records.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Splitting up a long running task with delayed job

2011-03-24 Thread Ar Chron
bingo bob wrote in post #989039:
> anyone done anything like this before?

What if you select 100 records per pass in an oldest-update == 
first-selected order?

model.Find(:all, :order => "updated_at DESC", :limit => 100)

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Nested Models are not connecting/connected

2011-03-17 Thread Ar Chron
R. K. wrote in post #987926:
> I'm attempting to make a basic CRUD/data entry cookbook. I've got a
> recipe model that is composed of other models. I'm intending of using a
> single form to create the recipes such that n ingredients and n
> instructions can be associated to a single recipe.
>
> I understand why it's not happening I just don't know how to make it
> stop.
>
> This is what I have so far as far as models and schema.rb:
>
> class Direction < ActiveRecord::Base
> belongs_to :recipe
>
> validates :number, :presence => true
> validates :instruction, :presence => true
>
> def step
>   "#{number}.) #{instruction}"
> end
> end
>
> class Ingredient < ActiveRecord::Base
>   has_one :measurement
>   belongs_to :recipe
>   validates :measurement, :presence => true
>   validates :quantity, :presence => true
>   validates :food, :presence => true
> end
>
> class Measurement < ActiveRecord::Base
>   belongs_to :ingredient
> end
>
> class Recipe < ActiveRecord::Base
>   has_many :ingredients
>   has_many :directions
>
>   validates :title, :presence => true
>   validates :description, :presence => true
>
>   accepts_nested_attributes_for :ingredients, :reject_if => proc { |a|
> a[:food].blank? }
>   #accepts_nested_attributes_for :ingredients, :reject_if => proc { |a|
> a[:food].blank? }
>   #we want to resuse ingredients if possible
>
>   accepts_nested_attributes_for :directions
>   #accepts_nested_attributes_for :directions, :reject_if => proc { |a|
> a[:instruction].blank? }, :allow_destroy => true
>   #there should not be an issue with deleting directions associated to a
> deleted recipe
>
>   #http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls#Procs
> end
>
> # This file is auto-generated from the current state of the database.
> Instead
> # of editing this file, please use the migrations feature of Active
> Record to
> # incrementally modify your database, and then regenerate this schema
> definition.
> #
> # Note that this schema.rb definition is the authoritative source for
> your
> # database schema. If you need to create the application database on
> another
> # system, you should be using db:schema:load, not running all the
> migrations
> # from scratch. The latter is a flawed and unsustainable approach (the
> more migrations
> # you'll amass, the slower it'll run and the greater likelihood for
> issues).
> #
> # It's strongly recommended to check this file into your version control
> system.
>
> ActiveRecord::Schema.define(:version => 20110314191853) do
>
>   create_table "directions", :force => true do |t|
> t.integer  "recipe_id"
> t.integer  "number"
> t.text "instruction"
> t.datetime "created_at"
> t.datetime "updated_at"
>   end
>
>   create_table "ingredients", :force => true do |t|
> t.integer  "measurement_id"
> t.string   "quantity"
> t.string   "food"
> t.datetime "created_at"
> t.datetime "updated_at"
>   end
>
>   create_table "measurements", :force => true do |t|
> t.string   "size"
> t.float"quantity"
> t.datetime "created_at"
> t.datetime "updated_at"
> t.string   "abbreviation"
> t.string   "measurement"
> t.string   "measurement_type"
> t.string   "equivalent"
>   end
>
>   create_table "recipes", :force => true do |t|
> t.integer  "ingredient_id"
> t.integer  "direction_id"
> t.string   "title"
> t.text "description"
> t.datetime "created_at"
> t.datetime "updated_at"
> t.string   "source"
> t.string   "image"
> t.string   "cooktime"
>   end
>
>   create_table "sessions", :force => true do |t|
> t.string   "session_id", :null => false
> t.text "data"
> t.datetime "created_at"
> t.datetime "updated_at"
>   end
>
>   add_index "sessions", ["session_id"], :name =>
> "index_sessions_on_session_id"
>   add_index "sessions", ["updated_at"], :name =>
> "index_sessions_on_updated_at"
>
> end

Basically, children need to know their parents. Take a look in the log 
at the queries generated, and you'll see items like:

Querying to show a recipe with id = 1:
SELECT 'directions'.* FROM 'directions' WHERE ('directions'.recipe_id = 
1)

So:

Recipe (top of the food chain - haha)
  # table has no _id fields
  has_many :ingredients
  has_many :directions

Ingredient
  belongs_to :recipe  # table must have recipe_id
  has_one :measurement

Measurement
  belongs_to :ingredient # table must have ingredient_id

Direction
  belongs_to :recipe # table must have recipe_id

That should make your app happier.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Uninitialized constant Files::Magick -still around

2011-03-17 Thread Ar Chron
Manny 777 wrote in post #987883:
> Hi Fred,
>  thank you for your reply. I tried to edit Gemfile by your hint, but
> unfortunatelly, without successful...
>
> But I found one interesting thing -- if I will to delete content of
> Gemfile, my app work normally (but of course, the problem with RMagick
> is here still), as if there the content was (in that Gemfile)... it's
> really weird...

I think you need to read up on how bundle works, and where it writes
information.

Edit your gemfile to your heart's delight.  If you don't run "bundle
install", then those changes aren't seen/processed.

Why weren't you successful with editing your gemfile? (your second post
in this thread)

It seems a relatively simple thing, and if you edited that file, and did
a "bundle install", and that process reported issues, then you should
resolve those.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: [RUBY] how do generate a random number w specific distribution ( which library ?)

2011-03-15 Thread Ar Chron
Colin Law wrote in post #987114:
>
> But how fast can you do it?
>

Ooh, that's an evil tweak... (a minor diversion which is much more fun 
than what I was doing)

Lenovo T61p, Core2Duo, T9300, 2.5GHz, ruby 1.9.2-p0

 = 0.253025

And for curiosity, my Ubuntu 10.10 VM on top of the same hardware:

 = 0.323791

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Fragment caching and not accessing model from view

2011-03-09 Thread Ar Chron
Colin Law wrote in post #986452:
> On 9 March 2011 11:54, Frederick Cheung 
> wrote:
>
> OK, I provided a scope
> scope :all_varieties
> with no parameters.
>
> Then in the controller
> @varieties = Variety.all_varieties
> and have confirmed that if the fragment is already cached so
> @varieties is not used in the view, then the query is not run, so no
> need test whether the fragment exists when setting up @varieties.
>
> This is the best solution I think.
>
> Thanks again
>
> Colin

Ack... obfuscated logic.  If you are trying to not make the call when 
the cache fragment already exists, then don't do so.

@varieties = Variety.all unless fragment_exist?( 'select_box' )

Don't squirrel it away behind a scope which does nothing except let you 
defer the decision about executing the DB read and depend on a behavior 
of AR which is determined when the view is being rendered...

Just a personal opinion.  What works for you, works for you.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Page Caching extending it?

2011-02-18 Thread Ar Chron
rails.n...@gmail.com wrote in post #982493:
> I guess this could also be done by implementing some sort of Fragment
> Cache... wrapping a whole page
>
> Just not sure where to begin... I don't want to reinvent rails
> caching... just want to tweak it with a simple conditional + have
> control on the file cache storage

+1 to fragment caching, as it is an easy-peasy solution to implement

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: howto implement a join table

2011-02-15 Thread Ar Chron
rogi wrote in post #981715:
> Hi There
>
> I have a table for the names of my workers and a table with the
> courses they have attended.
> Now I try to create a join table to see which workers attended what
> courses.
>
Assuming you have completed something like this:
rails g scaffold worker first_name:string last_name:string
rails g scaffold course name:string description:text

(since you seem to be new to Rails, allowing Rails to generate a full 
scaffolded solution is nice as an instructional tool - it gives you 
something to review to see how the Rails conventions would do the 
task... not that anyone leaves the scaffolded solution in place when 
actually in production, but I still use it for quick brainstorming 
sessions with users who have become accustomed to seeing the "ugly 
scaffolded views" when testing out concepts.)

I prefer the has_many through construct, since 99.9% of the time I 
always want to store some additional information in the join table, and 
having to use the "proper" name for a HABTM join table - is it 
worker_course or courses_workers, etc - has always irked me...

Now do:
rails g scaffold training worker_id:integer course_id:integer
  start_date:datetime end_date:datetime hours:float
rake db:migrate

in worker.rb, add
  has_many :trainings
  has_many :courses, :through => :trainings

in course.rb, add
  has_many :trainings
  has_many :workers, :through => :trainings

in training.rb, add
  belongs_to :worker
  belongs_to :course

should get you going from the data perspective. A partial displaying the 
training for a worker would be good, as would a partial for a course 
showing the trainings.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Suggestion to reduce number of junk hierarchical 'if loops'

2011-01-31 Thread Ar Chron
PalaniKannan K wrote in post #978680:

You have a few paths which will yield nothing (no executions, no 
output).

if !condition1 - nothing occurs
if condition1 and condition2 and !condition3 - nothing occurs
if condition1 and !condition2 and !condition6 - nothing occurs

Scope your data access (either description or tale2) to eliminate those 
cases from the data considered, then simplify your logic.

Less data to paw through with the rest of the code, and case might be a 
better construct for readability.

BTW, what are all those execution steps?

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: counTRY_CODE_SELECT

2011-01-24 Thread Ar Chron
Loganathan S. wrote in post #977147:
> Hi,
>
>  I'm new to rails ,the country_code_select plugin is not work  in my
> rails 3
> application,it just displays an empty select box,how can i correct this.
>
> Regards,
> Loganathan.S

Simple! Just correct either your controller, your model, your view code, 
or some combination thereof.

Seriously, I don't think any specific help is available if you don't 
provide some information on how you tried to use it.

If you have a control showing up empty, then it's missing its data. 
What's the source supposed to be?

Does that plugin require code in the controller to provide the data? Or 
perhaps in the associated model? Is it reading a YAML file, or making a 
call out to the web to some other service for the data?

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Magick::Image , no size & Amazon S3

2011-01-24 Thread Ar Chron
comopasta Gr wrote in post #977118:
> Hi,
>
> Any ideas why I get "undefined method `size' for   100x100 DirectClass
> 8-bit:Magick::Image" while doing the next?
>
> image = Magick::Image.new(100, 100) { self.size = "100x100"}
> logger.info image.size
>
...
>
> This is how I use it normally to store to file system and goes fine.
>
> @qr = RQRCode::QRCode.new("Some text" :size => 6)
> FileUtils.mkdir_p "public/images/tags/#{ident}"
> @img = QRImage.new(@qr).sample(1)
> path = "public/images/tags/#{@tag.identifier}/#{ident}_thumb.png"
> @img.write(path)

Well, what you're trying to do in the top section would seem to indicate 
that there isn't a size attribute available, or the method chaining is 
getting scrambled.  And the second filesystem example doesn't really say 
anything about 'size' as you aren't interrogating the size attribute in 
that code.  All that aside...

Have you tried it in irb?  And perhaps

Magick::Image.new( size => '100x100' )

(totally untested, and theoretical)

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails on Windows, so slow

2011-01-18 Thread Ar Chron
eJay wrote in post #975656:
> Frankly I do not want to go to Linux because I will not miss the
> editor Photoshop and Gimp for me is not quite acceptable.
>
> Who uses a Linux?

At home, I dual boot Win7 Pro (home stuff and fun stuff) and Ubuntu 
10.04 (Rails development work) since the machine is mine to control.

At work (i.e., not mine to control), I run Ubuntu 10.04 in a VM on top 
of Win7 Enterprise.

Have done Rails development under both Ubuntu/Linux and Windows to 
compare, and the Windows experience finished in a distant second place.

Ubuntu in a VM > Windows native.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: collection_select problem

2011-01-17 Thread Ar Chron
wardenik wrote in post #974738:
> <% @users.each do |u| -%>
>  ">
>   <%= u.name %>,<%= u.member_status_id %>
>   <%= collection_select( u, :member_status_id, blah blah blah %>

Please, please, please get that collection_select data access out of the 
view.

If you have 100 users, how many times will you exec that code?

Retrieve your @member_statuses in the controller, once, and use that var 
in the view.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Link_to parameters

2011-01-05 Thread Ar Chron
David Zhu wrote in post #972696:
> Hello,
>
> I would like to have a link_to automatically populate a field in the
> form that it is linking to.
>
> For example (excuse my silly words, im trying to make a point)
> <%= link_to "Add a COOL Post", new_post_path, :howcoolisit => 'COOL'
> %>
> <%= link_to "Add a NOTCOOL Post", new_post_path, :howcoolisit =>
> 'NOTCOOL' %>
>
> Then, I would have a field in that form:
>
> <%= f.hidden_field :howcoolisit %>
>

Are you reading the params[:howcoolisit] value and assigning it to @post 
in the 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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: ActiveRecord aliases 'id' to primary key

2010-12-10 Thread Ar Chron
Pete Campbell wrote in post #967747:
> Its a good suggestion but sadly the answer is no. There is another app
> that also accesses this data and so I *probably* can't change it.
>
> Is this behavior expected or not? It was a bit of a surprise to me.
>

A little unexpected... but the source makes it obvious what is 
happening.

module ActiveRecord
  module AttributeMethods
module Write

  blah blah blah

  def write_attribute(attr_name, value)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'

Seems like it ought to check and see if
  set_primary_key = something other than "id"
is set in the model and behave accordingly (if "id" is not the model's 
primary key, then don't remap attr_name to self.class.primary_key).

Of course, I've just looked at this one small snippet of code, and there 
may be other places in the AR code base that use 'id' as a name alias 
for the primary key (whatever it is), so removing that bit of 
redirection might totally hose up AR.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails 3 Active Record query returns "undefined method `loaded?' for #"

2010-12-09 Thread Ar Chron
David Kahn wrote in post #967449:
> I am getting this error on an rspec test:
> undefined method `loaded?' for #
>
> When I call:
> Practice.includes("practice_members").all
>

You aren't testing what you think you are...

.all returns an array even if it only finds a single instance, and at 
last check, the Array class does not have a loaded? method.

Should your test be using some other method, perhaps empty?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: beginning web development with ror, how?

2010-12-08 Thread Ar Chron
Umarzuki Bin Mochlis Moktar wrote in post #967122:
> thanks

Then again, there's always this:

Why's Poignant Guide to Ruby...

http://mislav.uniqpath.com/poignant-guide/

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Again on facebook

2010-12-06 Thread Ar Chron
If YOU don't know how you want to use the data in your application, then 
why are you asking here???   Why are you even worried about it?

If getting Rails/Ruby to hook up to facebook was just a technical 
exercise to learn an interface, then be done with it.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: persisting complex (and possibly large) objects

2010-12-02 Thread Ar Chron
Fearless Fool wrote in post #965610:
> This question may be so obvious that even Marnen won't answer it... :)
>
> I need to store a set of relatively complex objects in the db -- in my
> case, these are discrete cumulative distribution functions: they take a
> long time to construct, but I want the lookup to be fast.  Since the
> lookup is essentially a binary search, a B-Tree or some variant would be
> a sensible data structure.
>
> I have choices: (a) I store entire YAML'd B-Trees, (b) I store simple
> data structure (e.g. arrays of numeric pairs) and spend time
> constructing a B-Tree from it, or (c) choose another approach that
> someone on this list points out.
>
> - ff

Tough to call... What's your intended usage scenario?

Depending on the resolution required from the CDF, could you just store 
built distributions in a table and query against it?

With normalized inputs and the right indices, the query should be fast, 
and trading off record count versus accuracy, you could always do a 
linear interpolation between any two stored points. Need higher 
interpolated accuracy? Then increase the resolution of stored points to 
minimize the interpolated gap.

Ugh... I gave up the practice of sadistics years ago, and now you're 
making me remember it... Curse you Red Baron!

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Heroku error msg:App Crashed

2010-11-29 Thread Ar Chron
Emanuel wrote in post #964744:
> /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/
> runtime.rb:64:in
>  `require': no such file to load -- sqlite3 (LoadError)
>
>
> u can see from the above line...i think it is an error regarding
> sqlite3 as i am using it with my application...and i think heroku is
> not supporting sqlite3...so what i have do now,,,

Have you ensured that the sqlite3 gem is available?  There are tons of 
examples out on the web about setting up a basic Rails app. sqlite is 
the default database for Rails, but you have to get the gem yourself. 
And sqlite3 is fine for development (just you on your machine), but not 
so well suited for multi-user scenarios with updating.

A simple google for "sqlite3 rails install" should give you plenty of 
references.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Heroku error msg:App Crashed

2010-11-29 Thread Ar Chron
Emanuel wrote in post #964621:
> where did it gone wrong? pls help...

>From what you've provided, there's no telling what is wrong... it could 
be anything.

Have you looked at any of the log files available?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: How to select single radio button & multiple checkboxes in RUBY (Watir Frame work), any one help

2010-11-24 Thread Ar Chron
chowdary wrote in post #963540:
> RUBY (Watir Frame work)
>
> from the following Radio buttons i have to select only one radio
> button then automatically ramaining  should disable.
>
> sample code for radio button
>
> Gender :
>  Male
>  Female
>  Other
>
>
>
> How to select multiple checkboxes  RUBY (Watir Frame work)

Not being familiar with Watir, my first question would be "What have you 
tried?"

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Better approach to set global values?

2010-11-24 Thread Ar Chron
John N. wrote in post #963524:
>
> def grab_settings
>@set = Setting.first

 @set.company_name ||= 'My Company'

> end
>

Well, you could always read the Settings, then impose your own defaults 
inside the grab_settings method.  Any code outside that method has no 
idea whether the value was read, or set by you. It just knows that the 
value is filled.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Conditional haml vs. erb precedence

2010-11-23 Thread Ar Chron
Brent Miller wrote in post #963232:
> During the conversion process, we want to keep the new
> views away from most of our users until they're ready for public beta.

Umm... yeah, that's called dev environment vs production environment. 
I've found it far easier to grant a beta a look into the dev environment 
than to muck about in the production environment - that is supposed to 
be production code, not the dev test branch.

Create a limited user for them to use in the dev environment during the 
beta period, then just delete that user (or simply invalidate the 
account if you like them and would use them as a beta again).

Nothing scores more brownie points with a beta (who is a volunteer after 
all) than when they login for the next beta period and see all their 
personal settings from the prior beta...

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: technologies needed to learn to be a good ror developer

2010-11-22 Thread Ar Chron
venkata reddy wrote in post #963052:
> Hi everybody...
>I am venkey here. very interested to learn ruby on
> rails.Though i have not had any experience  with the web development,
> i want to learn ror as quickly as i can.I installed ror successfully.i
> am just starting to build sample applications.so anybody can tell me
> the path, like what is technologies i nead to learn to become a good
> ror developer.

Well, obviously, Ruby as the language, Rails as the framework, MVC to 
understand how it all fits together, and some database to work with 
(MySQL, SQLite, Postgres seem to be the top contenders). Javascript 
comes in handy, CSS, and I personally use HAML as my markup in 
preference to erb as I find it cleaner to read and write.

> and the right path to learn ror and list of resources
> available on the net and editors and tools needed to develop these
> applications.

Google is your friend for Rails development, just make sure the 
tutorials/examples you are following match the version of Ruby and Rails 
you have installed. Ryan Bates has a number of very good tutorials on 
useful topics. Do bookmark the Ruby and Rails API docs in your browser.

Start your application small and build up from there (learn to walk 
before you try to run). Get basic CRUD working, then extend. You will 
want to learn at least one of the automated testing tools for Rails, 
google that topic as well.

Editors? Feh, I use gedit on Linux, CodeWright on Windows. That's all 
you need, no fancy code-completing needed here, basic syntax 
highlighting is plenty.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: connect Model not to Controller named as pluarize of model but to another Controller

2010-11-18 Thread Ar Chron
sukury47 wrote in post #962465:
>
> ps. As i've practiced rails, i thought that
> Controller not named as pluarize of model is bad structure of app
> is it real? do you think so two?

Yes, it annoys me that there are so many examples for Rails like that.

In Rails, part of the beauty is the idea of convention over 
configuration. Conform to the 90% case and life (and coding) is easy.

Yet so many "introductory" tutorials begin with a non-conforming case.

It wasn't until I really looked at ALL the code generated by a simple

rails generate scaffold person first_name:string last_name:string

that it all started to make real sense.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Very confused - scaffold action does - sends NULL to db

2010-11-17 Thread Ar Chron
comopasta Gr wrote in post #962162:
>
> Do another scaffold named act and everything goes fine with no changes.
> I could imagine that action is a reserved word but shouldn't it complain
> about it?
>
> Any hints?

I'd imagine that your use of a reserved word has caused the issue, so 
don't.

I am admittedly curious... (but too lazy to spin up my VM at the 
moment).

What does the log show for the POSTed values?

Unless you are willing to do the delving into the rails codebase, this 
is one of those simple "Don't do that" cases.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Inheritance alternative

2010-11-06 Thread Ar Chron
Matias Fierro wrote in post #959653:
> I have to objects with common functionalities and a lot of difference.
> So I want that each have his own table but inherit the common
> functionalities from a parent class. How can I do this in Rails ?

class GenericModel < ActiveRecord::Base
  self.abstract_class = true

  # define all the 'common' methods you want in this class
  # (including the default behaviors for common methods)
  # I use methods in this class for providing all my cache
  # fragment management functionality, rendering model instances
  # to PDFs, etc, etc
end

class Person < GenericModel
  # person-specific methods, and overrides of common methods
  # from GenericModel
end

class Address < GenericModel
  # address-specific methods, and overrides of common methods
  # from GenericModel
end

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: pattern findings using “find” in Rails

2010-10-26 Thread Ar Chron
PalaniKannan K wrote in post #957235:
>
> I tried
> def author_yr
>  "#{self.author_year.last(4)}"
> end.
>
> But it shows "Undefined local variable or method 'author_yr'"
>
> when i use author_yr in find by
>
> ":order => ["author_year like = ?", author_yr]". Please suggest me some
> idea
> in ordering.

> Palani Kannan. K,

Impossible.

You're defining author_yr in a ruby model, but expecting the DATABASE to 
know what that is. Doesn't work that way.

As Fred mentioned, you need to use a database function that looks at the 
"author_year" field (the last 4 characters) to order upon.

Look in the manuals for whatever DB engine you're using for string 
functions.  That's what goes in the :order => []

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Problem with Sortable Table Columns

2010-10-25 Thread Ar Chron
>
> 12| @users = User.find(:all, :order => sort_column + " " +
> sort_direction)

Well, which value is null, sort_column or sort_direction?

Oftentimes, I've seen code that sets the direction for descending, but 
not ascending, which might be your issue.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: pattern findings using “find” in Rai ls

2010-10-25 Thread Ar Chron
Refactor the DB to have those fields available separately.  You have two 
distinct pieces of data munged together in one field.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Could not find a valid gem 'xaws-s3x' (>= 0) in any repository

2010-10-22 Thread Ar Chron
Peter C. wrote in post #956221:
> No, I am using RubyMine. It complains "Gems required for project are
> not attached: xaws-s3x (0.4.0)"

Can't help you there as I don't use an IDE (tried a number, and they 
just kept getting in the way).

But I assume that there is some sort of gem manager built into the IDE 
so it can recognize their usage?

If so, have you added the aws-s3 to whatever that list is?  And does it 
look at the necessary repository to find it?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: 13" MBA or 15" MBP?

2010-10-21 Thread Ar Chron
Alexander H. wrote in post #956067:
>
> I would be very grateful to hear any comments and recommendations by
> developers who have experience with this kind of development on
> MacBooks.

Screen real estate trumps all (IMHO), but then I'm a visually-oriented 
person.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: print page and Link_to problem

2010-10-20 Thread Ar Chron
Cameron Vessey wrote in post #955866:
>
>   So heres were I go dumb again... I added a print_label view to the
> tire view folder ...
>   "map.resources :tires" does nothing for this new view  
>  I must force the route into tires?
>>

map.resources :tires

generates the 'standard' CRUD routing.  There are two additional options 
I'll mention (probably should have done it earlier)...

:collection and :member

:collection lets you define additional routes that work on a collection 
of that resource

map.resources :tires, :collection => {:thumbnailed => :get}

would give you

<%= link_to "Thumbnails!", thumbnailed_tires_path %>

targeted at

def thumbnailed
  # your method code here
end

in the tires controller, which by default expects a

thumbnailed.html.erb  view file


:member lets you define additional routes that work on a specific 
instance of the collection

map.resources :tires, :member => {:print_label => :get}

would give you a

<%= link_to "Print a Label", print_label_tire_path(tire) %>

targeted at

def print_label
  # your method code here
end

in the tires controller, which by default expects a

print_label.html.erb  view file.

You can add as many collection and member routes as you like in 
routes.rb

This is all probably better explained at 
http://api.rubyonrails.org/v2.3.8/classes/ActionController/Resources.html 
around the middle of the page.

Remember to restart your server after changing the routes.rb

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: print page and Link_to problem

2010-10-20 Thread Ar Chron
Cameron Vessey wrote in post #955645:
>
> The index page has a link_to that looks like
>
> <%= link_to 'Edit', edit_tire_path(tire) %>
>
> now maybe I'm missing it but I've tried to find out were the scaffold
> put the route or mapping of this edit link_to so that it works.
>

Try executing a "rake routes >routes.lst" in your app folder, then take 
a look at the contents of routes.lst.

There you'll see the all routes (and path aliases) that Rails 
'magically' creates from the info in your routes.rb file.

edit_tire
new_tire
tire

in all the supported flavors of HTTP verbs.  Just append a _path, and 
there's your routing alias.

edit_tire_path(tire) is equivalent to

:controller => 'tires', :action => 'edit', :id => tire.id

unless I haven't had enough coffee this morning.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Could not find a valid gem 'xaws-s3x' (>= 0) in any repository

2010-10-19 Thread Ar Chron
Peter C. wrote in post #955385:
> Hi
> I'm trying to install xaws-s3x but got this error. Any advice or
> suggestion is much appreciated.
> r...@ubuntu:/d# gem install xaws-s3x
> ERROR:  Could not find a valid gem 'xaws-s3x' (>= 0) in any repository

Do you mean to install aws-s3?  What are the 'x's about?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: New to RoR. New project with a legacy database and php service. Any tips?

2010-10-19 Thread Ar Chron
William Denniss wrote in post #955352:
> Hi All,
>
> I'm about to jump into Ruby on Rails for a new project, but wanted to
> see if anyone has some tips for my specific situation:
>
> Basically I already have a web service in PHP that communicates with a
> non-web based application to sync data between instances, storing the
> data in MySQL.  This is all working great, and there is no need to
> change it.
>
> I now wish to add a web based front end to this system, and am looking
> at RoR to do it.
>

I assume you're looking to have Rails work with that MySQL database?  If 
so, then any concerns about php and the sync'ing service are moot.

>
> Regarding the legacy database:
> -Any pointers on reconfiguring an existing database to use rails?  Do
> I *have* to rename all the primary keys to 'id' ?
> -Should I re-create the structure in migrations, or just manage
> things the old way (i.e. big list of sql update statements)
>

You don't *have to* add an id column to all your tables, but it will 
definitely make life easier for creating your Rails app if you do, 
otherwise just be sure to read up on your ActiveRecord methods.  Using 
something other than id as the key is definitely supported.

>
> The web site will be basic CRUD, but with one exception:
>
> I can't just use the standard "Update" functions of RoR (i.e. the ones
> that map to an UPDATE SQL statement).  The design is this: I never
> update any rows on this database, rather I insert the record again,
> and mark the old one as "old".  This is done to give users an
> unlimited undo function (think a little like how Wordpress does it)
>
> - Do you have any suggestions to get me started on overriding the
> model's standard update function to instead do this special handling?
>

Might be a couple of ways to do this, but it kind of depends on how you 
mark a record as 'old' - in the past I've used a 'valid_until' field. 
Any current, valid records just don't have an expiration date, expiring 
a record could be done by setting that value just before creating the 
new record (before_save callback?).

> - I may also need to override the "Read" function to use not the
> primary key, but different unique key I give the record, one that
> doesn't change between revisions (and also to only return the newest
> version).  Will this be difficult?
>

Not hard, see ActiveRecord mentioned above.

>
> Finally, what is the simplest way to interface with an internal PHP
> service?  Do a JSON formatted http://localhost request and just get
> back the array of data?

Your Rails app will have to post requests in a format understood by the 
php service, and deal with whatever it gets back, be that Json or POX or 
something else.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: using custom foreign keys in associations

2010-10-19 Thread Ar Chron
Arun Srini wrote in post #955342:
>
> class CreateRoomtypes < ActiveRecord::Migration
> create_table :roomtypes do |t|
>   t.string :t_name
>   t.string :rate
>   t.string :comment
>   t.timestamps
> end
> end
> class CreateRooms < ActiveRecord::Migration
> create_table :rooms do |t|
>   t.string :name
>   t.boolean :avail
>   t.string :type_name  - to reference Roomtype's name
>
>   t.timestamps
> end
>   end
>
> I want to use type_name column of Rooms as foreign key to Roomtype
> model. I tried running below queries but in vein. What am I doing
> wrong? How to 'plumb these together'?
>

Since you do seem to be defining the rooms table, why not use the rails 
'traditional' roomtypes_id field as your key?  It is much clearer (I 
know what that field is, and I know where it connects to), it is the 
'convention over configuration' solution, and it alleviates any 
potential issue with someone in the future deciding that "Oh, that room 
type name doesn't really fit anymore, can I change it?" - I personally 
abhor descriptive strings as keys for precisely that reason...

Leave some of that DB world training behind and embrace the 'rails way', 
you'll be much happier, and things tend to fit more naturally.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Ruby as a web client

2010-10-15 Thread Ar Chron
Alex wrote in post #954625:
> Hello,
>
>  I need to write a program that will talk http to some web
> applications. I was thinking to use Rack. I am not sure what would be
> a good way to do this. Is there a better or higher level gem that I
> can use for this.
>
>
> Thanks in advance!
> Alex

You could also peruse httparty (I think that's the name of a gem I 
used)...

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Noughts and Crosses layout with a variable number of entries

2010-10-15 Thread Ar Chron
Pale Horse wrote in post #951715:
> Apologies for omitting the code you provided - I needed to reduce the
> number of quoted lines.
>
> Thanks very much, I'll give that a try. I should've considered the
> in_groups_of method before.
>

Bah, my last_col_pos calc is wrong... rather than group.length-1, try 
group.nitems-1   Taht should ignore any nils added if there aren't 3 
items in a group

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: How old are you?

2010-10-12 Thread Ar Chron
David Kahn wrote in post #947370:
> So if you dropped the box and they got out of order
>

That's why any "serious" programmer back in those days (not that I would 
know personally of anything like that) carried colored markers to mark 
stripes diagonally across the top of the batched deck...  helluva lot 
easier to do the first order sort just by lining up the stripe...

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: What is the best way to learn rails 3.0 with no prior rails experience?

2010-10-07 Thread Ar Chron
egervari wrote:
> What is the best way to learn rails 3.0 with no prior rails or ruby
> experience? I'm just curious about it and want to get started.
> 

Get ruby 1.9.2/rails 3/gems installed - tons of tutorials out there for 
a basic setup.

Buy the Pickaxe book (is it still a pickaxe for Ruby 1.9.x)

mkdir rails
cd rails
rails new testapp
cd testapp
rails g scaffold person first_name:string last_name:string

now sit down and read through the generated code to see how rails WANTS 
to work.

You wouldn't use a generated app for a real production application, but 
as an educational tool, it's a great way to get started.

Heck, I still scaffold a basic proof of concept when users come to me 
for the "next great addition" to our system.  They even expect the 
initial forms to be ugly but workable...
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Drop-down menu from a belongs_to association

2010-10-07 Thread Ar Chron
Leonel *-* wrote:
> Now I have this at the form partial
> 

Hmm...  give this a whirl

appointments controller:

def new
  @appointment = Appointment.new
  @clients = Client.find(:all)
  respond_to do |format|
format.html # new.html.erb
format.xml  { render :xml => @appointment }
  end
end

views:

new.html.erb probably just says "render 'form'"?

_form.html.erb


  <%= f.label :client_id %>
  <%= collection_select("appointment", "client_id", @clients, "id", 
"name", {:include_blank => true}) %> 

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: where i should report an issue

2010-10-07 Thread Ar Chron
Amit Tomar wrote:
> Hii all,
> where should i report an issue means its mongrel issue where
> could i report this

Sheesh, do a little research...

Google mongrel, and you'll find

http://rubyforge.org/projects/mongrel/  among the links returned.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Good idea to send encrypted password with activation link

2010-10-06 Thread Ar Chron
Felix Samy wrote:
> Is this good idea to send activation link with encrypted password

Why would you want to send the encrypted password anywhere?
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: what is that get in routes?

2010-10-06 Thread Ar Chron
If you generated that controller then perhaps rails assumed a GET was 
the safest thing to default?
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: NoMethodError

2010-10-01 Thread Ar Chron
> namespace :Geo do
> desc 'Update cartcid with longitude and latitude information'
> task :add_cartcid_coordinates => :environment do
> include GeoKit::Geocoders
> c = Cartcid.find_by_sql(["SELECT address  FROM cartcid WHERE
> ADDRESS IS NOT NULL"])
> begin
> c.each { |cartcid|
> loc = MultiGeocoder.geocode(c.address)
> c.lat = loc.lat
> c.lng = loc.lng
> c.update
> puts "updated cartcid #{c.nome} #{c.address} =>
> [#{loc.lat}, #{loc.lng}]"
> }
> rescue
> puts $!
>  end
>  end
> end

Still wrong... you did the exact same thing as before in another way...

> c = Cartcid.find_by_sql(["SELECT address  FROM cartcid WHERE

Given your code, "c" is an array (of Cardcid's) - and the Array class 
does not have an address attribute.

> c.each { |cartcid|

Given this line, you are processing each individual element in "c" in a 
variable named "cartcid"

> loc = MultiGeocoder.geocode(c.address)

Now you are referencing the array "c" again!!! Just like you were doing 
in your earlier post.  That line needs to be:

loc = MultiGeocoder.geocode(cartcid.address)

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: NoMethodError

2010-10-01 Thread Ar Chron
You're re-using your geotable variable inappropriately... try:

geotables = Geotable.find_by_sql(["SELECT * FROM geotable WHERE ADDRESS 
IS NOT NULL"])
begin
  geotables.each { |geotable|
loc = MultiGeocoder.geocode(geotable.address)
blah blah blah

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Seeking RoR Development Shop for TOP SECRET project

2010-10-01 Thread Ar Chron
No no, you've missed it...

> We are looking for a team of 15 full-time RoR programmers ...
...
> - Have a Seasoned Team of 25+ who have worked together for 3+ years


Hmm, 15 developers.

Add in 1 QA person for every 3 developers, and that gets us to 20.

Add in an overbearing DBA to complain that the devs shouldn't be writing 
migrations to muck with *his* database, and we're at 21.

A Doc person or two for maintaining requirements and documentation, and 
we're at 23.

A 'Rawkstar' Development Project Team Lead who knows all the nuances of 
Ruby, Rails, HTML, CSS, Javascript, PostgresSQL, Oracle and the origin 
of the universe, and we're at 24.

All we need now is a pointy-haired boss to get to 25!

(yeah, I know this isn't helpful, and its all OT, but I'm running on 3 
hours of sleep today so I'm a little punchy...)

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Railroad problem with :through?

2010-09-29 Thread Ar Chron
Sem Ptiri wrote:

Is this a typo, or your problem source?

> class Subscriber < ActiveRecord::Base
> has_many :lists
> has_many :lists, :through => :list_subscribers
> end
> 

class Subscriber < ActiveRecord::Base
  has_many :list_subscribers
  has_many :lists, :through => :list_subscribers
end
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Newbe question

2010-09-28 Thread Ar Chron
I think one of your key design decisions up front is who defines the 
tags/keywords?

If it is left up to the users to enter tags, then you might look into 
the has_many_polymorphs gem and the tagging facilities available there. 
This case makes it a tad more difficult to deal with searches, because 
your users can enter tags willy-nilly, and you have to come up with some 
method of classifying them, ideally dealing with synonyms and 
misspellings.

User-defined tags opens you up to some, er, inappropriate tags as well 
if your application is ever found out by the spam-spiders that crawl the 
web (a blacklist of tags to ignore would be your friend in this case I 
think).

If you are defining the keywords, it becomes much more manageable, and 
you can classify the tags you support according to types... salary 
ranges, experience levels, locations, whatever. I usually include 
something like a code table in my apps, where I can setup a codetype 
(string), codevalue (int), and codetext (string) where I could enter 
things like below that can be used in droplists for selection of 
attributes.

type, value, text:
"salary", 1, "30-40k"
"salary", 2, "40-50k"
blah blah blah
"experience", 1, "1-3 years"
"experience", 2, "4-6 years"
etc, etc
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Uploading photos

2010-09-28 Thread Ar Chron
I would think it is much simpler...

Be sure you have ImageMagick installed (or an alternative)
Be sure your migration defined the logo_file_name, logo_content_type, 
logo_file_size in the jobs table.

My example:

class Stage < ActiveRecord::Base
  # cycling race stage
  # belongs to a race-year, like 2010 - Vuelta d'Espana
  # has many stage standings (rider finish order)
  # has attached images for the route
  #   map and the elevation profile
  belongs_to :raceyear
  has_many :stagestandings

  has_attached_file :map, :styles => {:thumb => '100x100>'}
  has_attached_file :profile, :styles => {:thumb => '100x100>'}
end

<%= form_for @stage, :html => {:multipart => true} do |f| %>

blah blah blah, fields to select raceyear, enter the stage name,
description, terrain and distance, relevant image upload fields
below

<%= f.label :map %>
<%= f.file_field :map %>

<%= f.label :profile %>
<%= f.file_field :profile %>

<%= f.submit %>
<% end %>

Paperclip does all the heavy lifting.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Uploading photos

2010-09-27 Thread Ar Chron
Piece of cake.. be sure to check out 'rails paperclip' via google.  Tons 
of useful examples.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: design decision

2010-09-27 Thread Ar Chron
If I understand the requirement, then the creation of an e-mail is the 
business of the model.

Controller should be deciding "After creation of model X, what view does 
the user see? To the index view, the show view of the model just 
created, or back to the view the user was at before creating the model?"

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: problem with the "detail"-method

2010-09-24 Thread Ar Chron
Marnen Laibow-Koser wrote:
> 
> Hast du ein URL?  I can read German (though I've never used Rails 3)...
> 

Hi Marnen,

I was trying to get an idea of the lesson by browsing the "course 
contents" in this pdf:

www.video2brain.com/de/pdf-toc-60.pdf
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: How to call a method in a controller with link_to?

2010-09-24 Thread Ar Chron

routes.rb

resources :messages do
  member do
get :tweet
  end
end

should give you a tweet_message_path to use in a view like

<%= link_to('Tweet This', tweet_message_path(message.id)) %>

and direct the app to your tweet method in the messages_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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: problem with the "detail"-method

2010-09-24 Thread Ar Chron
>From earlier in the post-stream:

class FormController < ApplicationController
  def index
@form = Form.find(:first)
@form.update_attributes(params[:form])

@detail = @form.detail
@detail.update_attributes(params[:detail])
  end
end

>From your log:

{"commit"=>"Speichern", "action"=>"index",
"controller"=>"form", "form"=>{"kurztext"=>"This is a test for the
talk"}, "detail"=>{"detailtext"=>"Test for the talk"}}


Something is truly bizarre with this example you are trying
to follow... and I can't say that I fathom the intent of
the example in the tutorial. So I went to look, and found a
PDF about Rails at video2brain, but unfortunately, Ich spreche
kein Deutsches.

Strange issues with this example:

You generally don't POST to the index method...  that's
usually a GET.

This code will always be modifying the first form due to the
Form.find(:first) statement... perhaps there is only supposed to
be one.

The detail model in params doesn't contain a form_id.  You could
remedy that by:

@form = Form.find(:first)
@form.update_attributes(params[:form])

if @form.detail
  @detail = @form.detail
else
  @detail = Detail.new
end

@detail.form_id = @form.id
@detail.update_attributes(params[:detail])

That should at least get you a value for form_id in
the detail model (you did add form_id as integer to your
details table, no?))

But this example is "wrong" in so many ways.  Finish it if you must,
then promptly forget this video2brain... gibberish.

Step up to Rails3, and find a couple of Rails 3 tutorials. You'll be
much better served spending your time on those.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Re: Re: problem with complex function to save in db

2010-09-24 Thread Ar Chron
Almog Friedman wrote:
> I didn't quite understand why did you put
> that:  @faction = Faction.find(:last, :order => 'id') at the end of the
> controller action.

In the code I posted, there is no @faction object populated from the 
params, and standard routing after a create is to go to the show for 
that @faction (the usual respond_to do |format| block).

Faction.create doesn't create one either, so I retrieved the one just 
created.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Re: problem with complex function to save in db

2010-09-23 Thread Ar Chron
Hmm... maybe you do need a table name involved:

Controller:

def create
  hash = params[:faction]
  hashnew = save_ids(hash, 'FactionContent')
  Faction.create(hashnew)
  @faction = Faction.find(:last, :order => 'id')
end

And that other routine:

def save_ids(arguments, table)
  ret = Hash.new
  arguments.each_pair {|key, value|
table.constantize.create(:english => value)
content = table.constantize.find(:last, :order => 'id')
ret[key] = content.id.to_s
  }
  return ret
end
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Re: problem with complex function to save in db

2010-09-23 Thread Ar Chron
Almog Friedman wrote:
> heres the log hope it'll help:
> 
Processing FactionsController#create (for 127.0.0.1 at 2010-09-23
21:46:39)
[POST]
  Parameters: {"commit"=>"Create",
"authenticity_token"=>"1f1aa67b947f0e23dc19aad8debc1e63b6df002c",
"faction"=>{"name"=>"asdasd", "name_plural"=>"asdasd",
"description"=>"asdasdasd"}}

FactionContent Create (7.4ms)   INSERT INTO `faction_contents`
(`created_at`, `updated_at`, `english`) VALUES('2010-09-23 19:46:39',
'2010-09-23 19:46:39', NULL)

no values for 'english' in any of the inserts

I think you're over-complicating things...

In factions_controller.rb:

def create
  # just grab the hash for the model being saved
  hash = params[:faction]
  # do the string to content record id magic
  hashnew = save_ids(hash)
  # save a new Faction record
  Faction.create(hashnew)
  # find the one just saved
  @faction = Faction.find(:last, :order => 'id')
end

And wherever you have this stored:

def save_ids(arguments)
  # saving the content is table agnostic, don't need that parameter

  # new empty hash to return
  ret = Hash.new
  # for the incoming arguments hash
  arguments.each_pair { |key,value|
# store each value in Contents
Content.create(:english => value)
# find the record just written
content = Content.find(:last, :order => 'id')
# replace the string just stored with a stringified id from Contents
ret[key] = content.id.to_s
  }
  # return our new hash
  return ret
end

worked for me...
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Confused with bcrypt and Authlogic

2010-09-23 Thread Ar Chron
CV wrote:
> Well, I didn't realize that there was a lower-level part to the
> library too! But unfortunately we're not there yet:
> 
> ruby-1.9.2-p0 > BCrypt::Engine.hash_secret("test",
> "Hki1ozSQrkmvGzddNJq")
> BCrypt::Errors::InvalidSalt: invalid salt

I wonder if Authlogic overrode any of the default settings for BCrypt?

What do you get using irb for @version, @cost, @salt, @hash after:

@version, @cost, @salt, @hash = BCrypt::Password.new(u.crypted_password)

on your test user?  Source docs indicate Password.new returns a 
quadruple:

 # File lib/bcrypt.rb, line 161
161: def initialize(raw_hash)
162:   if valid_hash?(raw_hash)
163: self.replace(raw_hash)
164: @version, @cost, @salt, @hash = split_hash(self)
165:   else
166: raise Errors::InvalidHash.new("invalid hash")
167:   end
168: end
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: problem with complex function to save in db

2010-09-23 Thread Ar Chron
Almog Friedman wrote:
> sorry but I'm kinda new with rails, i don't know how to get a log of the
> hash itself.
> how do I do that?

development.log should be in a folder like:

C:\rails\appname\log\development.log

or

home\druid\rails\appname\log\development.log in a *nix envt.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Confused with bcrypt and Authlogic

2010-09-23 Thread Ar Chron
Should you be using something like:

if BCrypt::Engine.hash_secret(password, u.salt) == u.crypted_password
  valid = true
end
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Confused with bcrypt and Authlogic

2010-09-23 Thread Ar Chron
CV wrote:
> ...but the result is "false". Do we need to work the salt in? And if
> yes, how? Trying to pass it as a constructor argument or trying the
> "salt" setter doesn't work.

You're saving the crypted_password and the salt that was used to create 
it, so the validation of a newly submitted password is to pass it 
through the same function and compare the end results...

Does Bcrypt of "newly submitted password" and u.password_salt == 
u.crypted_password
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: problem with the "detail"-method

2010-09-23 Thread Ar Chron
Sven Wildermann wrote:
> You have a nil object when you didn't expect it!
> You might have expected an instance of ActiveRecord::Base.
> The error occured while evaluating nil.update_attributes"
> 

Can you show the POST from your log file...  I'd like to see what your 
params hash looks like.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Connecting several tables in single database

2010-09-23 Thread Ar Chron
You are probably getting an "undefined method 'cities' for #" error.  Address each hierarchy level in turn...

<% @names.each do |name| %>
  <% name.cities.each do |city| %>
<%= city.local_area %>
  <% end %>
<% end %>

<% @names.each do |name| %>
  <% name.countries.each do |country| %>
<%= country.state %>
  <% end %>
<% end %>

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: problem with complex function to save in db

2010-09-23 Thread Ar Chron
TEREN wrote:
> 
> this is my function:
>   def save_id(arguments, tables)
> arguments_id = arguments
> arguments.each_pair do |key, value|
>   pair = { :english => value}
>   tables["content"].new.save(pair)
>   content_id = tables["content"].find(:first, :order => "id
> DESC").id
>  # @pair2 = {key => @text_id}
>   arguments_id[key] = content_id
> end
>   tables["table"].new.save(arguments_id)
>   end
> 
> the arguments are the parameters i get from the form
> the tables variable holds the models i use and looks like this:
> TABLES = {"table" => Faction, "content" => FactionContent}
> 

Well...  can you show us what an actual POST looks like from your log? 
It would help to see the contents of the actual params hash.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Multipe Combo box Query System

2010-09-23 Thread Ar Chron
You should look into:

http://stackoverflow.com/questions/575862/rjs-using-observe-field-on-select-tag

for info on how to use observe_field in combination with a select.  I 
just did a sursory review, and it looks like a decent solution 
guideline.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Connecting several tables in single database

2010-09-23 Thread Ar Chron
PalaniKannan K wrote:

> *name model*
> has_many :city, :foreign_key => "name_id"
> has_many :country, :foreign_key => "name_id"
> *

has_many models should be pluralized

class name < ActiveRecord::Base
  has_many :cities
  has_many :countries
end
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: problem with the "detail"-method

2010-09-23 Thread Ar Chron
Sven Wildermann wrote:
> class FormController < ApplicationController
>   def index
> @form = Form.find(:first)
> @form.update_attributes(params[:form])
> 
> @detail = @form.detail
> @detail.update_attributes(params[:detail])
>   end
> end
> 

IIRC, given the code above as the main clue, you might need:

class form < ActiveRecord::Base
  # a form model has a related detail model
  has_one :detail
end

class detail < ActiveRecord::Base
  # and vice-versa
  belongs_to :form
end

The details table needs to have a column named form_id, spec'ed as 
integer, the forms table gets no additional field.

If there can be more than one detail model related to a form, then just 
the form model specification changes...  it notes has_many, and the 
related model is pluralized.

class form < ActiveRecord::Base
  # a form model has a related detail model
  has_many :details
end

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails-2.3.8 routing question

2010-09-21 Thread Ar Chron
Look into the routing docs for :member and :collection options.

http://rails.rubyonrails.org/classes/ActionController/Resources.html
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: routing ... Mapping... can only get to index

2010-09-20 Thread Ar Chron
Cameron Vessey wrote:
> You don't get it.
> 

Sorry dude, but you are the one who doesn't get it.  Your posts 
'smelled' a great deal like a total newbie post, and as such elicited a 
response directed at a total newbie.

It may not have occurred to you that your spelling of user_loggin didn't 
strike Marnen (or I) as a "Say, he's a right smart bloke, and I bet he's 
not spelling the word correctly on purpose." type of posting...  Right 
or wrong, there are tons and tons of ESL posts on this board that 
probably colored the response to your post. My initial thought was "Oh 
crap, another person trying to code php in Rails..."

Your subsequent comment that "and it messes with URL routing or some 
thing ..." in your second post also sent up red flags for me that 'Why 
this bloke seems to have no clue what he's talking about."

>From your fourth post:  "Why would I use restful if I have no clue how 
to use restful?"

Umm... perhaps because long-time readers and posters on the forum assume 
that you come to this forum to learn from people who have already 
traveled the road you seem to be on...  perhaps because restful routes 
is a big thing in Rails, which happens to prefer convention over 
configuration, and you seem to be thinking configuration, so perhaps a 
redirect was in order...

A great place for information is api.rubyonrails.org; another great 
place is your own machine in the console window, and your development 
log.  Look in the dev log to see what the parameters are that your app 
is receiving. Read the api (particularly the routing part) to better 
understand that piece.  When you used scaffold, did you just scaffold 
the full deal (something like: script/generate scaffold person 
last_name:string first_name:string ).  That'll generate the controller, 
model, views, routing - rake that migration then play with that basic 
app - read through the generated code to learn how it all fits - it is 
amazingly educational about the Rails conventions.  Generally, if it is 
hard to do, you're doing it wrong. Simple as that.

I don't always agree with Marnen's opinions, and he does tend to state 
things a bit strongly for my taste, but I do always read his posts. 
Why? Because he knows more than I, and a hell of a lot more than you.

But as your later posts have indicated, you are not interested in 
learning from anyone more knowledgeable than you in Ruby and Rails, you 
just want an answer to your 'user_loggin' question so you can write the 
code your way, however against the conventions of Ruby and/or Rails it 
might be.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Problem about "no action" error

2010-09-20 Thread Ar Chron
kun niu wrote:
> Hi all,
> I'm a ROR newbie. I'm writing ROR application on Ubuntu 10.04, ruby
> 1.8.7-p249, rails 2.3.5, mongrel 1.1.5. I wrote a controller called
> "admin". 

Okay, that is nice...

> I also defined a function in the corresponding controller
> called "show_admin". 

Not so nice...  Rails works the best and the easiest if you adhere to 
the Rails conventions.  You should start with a basic tutorial somewhere 
and follow it, trying to understand how it all fits.  My favorite way to 
get people started is to tell them to scaffold a basic application, then 
see what the generator created, and understand how it works.  Later, 
worry about an admin, or namespacing.

script/generate scaffold person last_name:string first_name:string

(that creates an initial db migration, controller, and views for a 
person)

rake db:migrate

(create the table)

script/server

Now browse to your app, and add a person or two, noting which link you 
clicked to do what. Now look at the application code AND your log file 
to see how Rails is wired togehter

> But each time I browsed to "http://localhost:3000/
> admins/show_admin". I always get the following error:
> No action responded to show. Actions: index, login, logout, and
> show_admin
> It seemed that ror find my action, But it failed to show the action.

No, that's not correct. Unless you updated your routes.rb file and 
restarted your server, you don't have a 'show_admin' routing. And you 
shouldn't have one, that very un-Railsy.

> On the other hand, it tried to show the "show" action. But I don't
> have such an action. I wonder if anyone here can solve my problem. I
> searched the internet. I found someone said that it might be related
> to the namespacing system. But I can find the detailed description
> since it was a google cache.
> Thanks for any hints or advice in advance.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Trying to look up comment through an ID, but failing

2010-09-17 Thread Ar Chron
Kelp Kelp wrote:
> 
> comments_controller#new:
> @comment_parent = Comment.find(params[:in_reply_to])
> 

Why not just:
   @comment = Comment.new
   @comment.parent_id = params[:in_reply_to] if params[:in_reply_to]

> 
>   <%= f.hidden_field :parent_id, :value => @comment_parent.id %>

and skip the :value assignment in the view, the value is already there

and you shouldn't need any of this...

>   @comment_parent = Comment.find(params[:parent_id])
>   @comment_parent.children << @comment

Unless a day spent in WCF has corrupted my brain too much...
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Twitter Plugin

2010-09-15 Thread Ar Chron
muralidharan K wrote:
> Hi All
> 
> I did search twitter plugin. I did n't get it. 

Then you need to practice your Google-fu more Grasshopper...

Google "rails twitter plugin" for tons of resources
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Populate combo box from database without repeatness

2010-09-09 Thread Ar Chron
PalaniKannan K wrote:
> But, I am unable to use params[:id] to get the selected value 
> from collection_select. how i can get selected value to params.
> 
> I need the flow
> collection_select (value selected) -> param[:id]-> find SQL row..
> 

The selected value is in params already, just not where you're looking.

Take a look in your log at the post request that rails receives when you 
submit the form... this information is all readily available there.

You should see something like:
Parameters: {"utf8"=>"blah1", "authenticity_token"=>"blah2", 
"model_to_populate"=>{"column_to_populate"=>"blah3",...}, 
"commit"=>"blah4", "id"=>"blah5"}

In your controller code,

params[:id] is the id of the 'model_to_populate' (blah5)

params[:model_to_populate][:column_to_populate] is the value stored by 
the collection_select statement in the view (blah3)

Parsing through and understanding your log files is something everyone 
should be comfortable with.  It's usually the first stop in performing 
triage on unexpected behaviors.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Hello

2010-09-09 Thread Ar Chron
There are probably a bazillion tutorials out on the web (well, maybe 
only a million). Google is your friend in this regard.

The forum members can't really recommend anything specific because we 
don't know even what your OS is, and the specific install instructions 
differ according to the OS.

And your post smacks of "no effort".

What have you researched?

What have you tried?
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Will a Quad-core i5 processor significantly speed up development on Linux or Mac?

2010-09-09 Thread Ar Chron
My own $0.02...

Buy the best machine you can afford to today, or wait. There will always 
be a better deal in a month, it's the nature of the beast.  And price vs 
performance is always a subjective matter. The i5 will have a longer 
useful lifetime, but I don't know how often you change your rig (I run 
about a 4 year cycle, and try to buy with that in mind).

During development, 99.999% of the time either machine will be waiting 
on you...

I've watched my quad-core Phenom II's work loads (who hasn't popped up 
that cpu usage window and left it there for a while?) and it rarely 
spikes above 30% in aggregate except when running automated test suites 
- at that point, it is satisfying.

Cores/processor speed aside, when I bumped the RAM in my rig from 4Gig 
to 8Gig, now that was satisfying.  If you can load up the used Thinkpad 
with 8 Gig, that might be the winner for me.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Expire cache in rake issue

2010-09-08 Thread Ar Chron
jazzy jazzy wrote:
> Hi All,
> I am trying to expire a fragment cache in rake. I know that the best
> practice to expire the cache is in the Sweepers. But as I have to expire
> the cache at the end of the month I was thinking on the lines of doing
> it in a rake task.
> I had tried this but it showed me an error while running the task
> 

You could look into Rails.cache.delete(path_and_fragment_name)
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Layouts in Rails 3.0

2010-09-08 Thread Ar Chron
Jaap Haagmans wrote:
> In my controller:
> 
> class ApplicationController < ActionController::Base
>   protect_from_forgery
> 
>   layout 'application'
> end
> 

Yank the

layout 'application'

statement and you should be fine.  My out-of-the-generator Rails 3 app 
honors the application.html.erb without any such statement.

class ApplicationController < ActionController::Base
  protect_from_forgery
end
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: no output

2010-09-08 Thread Ar Chron
ishu wrote:
> I am working on rails 9.10 n ruby 1.9
> I have used rspec in the application.
> While using rake spec command, i am not getting any output.
> Help me at the earliest.

I assume you mean Ubuntu 9.10 as the OS, ruby 1.9.something, and an 
unknown version of Rails...

not much help anyone can offer without more details...  what do the logs 
say?

You might want to look at

http://wiki.github.com/dchelimsky/rspec/ruby-191

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Populate combo box from database without repeatness

2010-09-08 Thread Ar Chron
a. Get your DB Access out of the views...

b. Read The Fine Manual on collection_select

c. Controller:

@vendors = TableName.find(:all).uniq  or some variant thereof

With a lot of records, you might want to use a find_by_sql and let the 
DB do the work with a "SELECT DISTINCT..."

d. View:

<%= collection_select("model_to_populate", "column_to_populate", 
@vendors, "id", "vendor_name_field") %>
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: problem with passing local variables to a partial view

2010-09-08 Thread Ar Chron
Why the whole :fp inside the partial?

Just use fp...
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Expire_fragment in observer/model? Works fine in Sweepers.

2010-09-08 Thread Ar Chron
Steven Cummings wrote:
> 
> Had this problem too and wrote up the solution the other night on my 
> blog.
> 
> http://stevencummings.name/2010/09/07/expire_fragment-with-rake-and-as-a-model-only-observer

Interesting solution...

Related to model-based cache expiration, in one large-ish Rails project, 
the sidebar for a 'show' of an entity contains a view of all the related 
entities in the application. We were getting hammered on both db access 
and rendering time, so I implemented fragment caching in a multi-tiered 
approach, and left it to the models to expire caches of their data -- a 
fine line to walk, but that worked the best for us.

We used a Rails.cache.delete() call from within the model to handle the 
fragment expiration, with the new/edited/deleted model selecting the 
appropriate caches to expire according to its related models.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Re: Re: Re: Re: problem when : ruby script/server

2010-09-07 Thread Ar Chron
radhames brito wrote:
> the only thing a bit hard about it is editing the rc file, tell me what
> linux you have and what shell i will see how i can guide you to install 
> RVM

To create one in Ubuntu, just a simple

sudo gedit .bashrc

in a command window from your home folder will create one, ready for 
editing as the rvm install instructions mention.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Caching

2010-09-07 Thread Ar Chron
Ar Chron wrote:
Er, ignore my math.
30 per page, edit/change 1, save rendering on 29, not 39... Doh!
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



  1   2   3   4   5   6   >