[Rails] Problems with fixtures and HABTM

2011-08-02 Thread Juan Kinunt
I have:

treatments.yml

treatment3:
  id: 3
  code: T3
  description: Desarrollo de una política de seguridad
  reduction: 0.3
  document: D01_Politica_Seguridad
  account_id: 1
  soa_lines: soa_line3
treatment4:
  id: 4
  code: T1
  description: Inclusión en el mantenimiento de los sistemas un chequeo
de la seguridad del navegador en uso.
  reduction: 0.1
  document: D10_Mantenimiento_Equipos.docx
  account_id: 2
  soa_lines: soa_line4

and:

soa_lines.yml

soa_line3:
  account_id: 1
  id: 3
  justification: La política de seguridad es fundamental para el
funcionamiento del sistema
  control_id: 3
  applicability: true
soa_line4:
  account_id: 2
  id: 4
  justification: Es necesario proteger las transacciones en línea que
realiza la organización
  control_id: 1
  applicability: true
  treatments: treatment4

And both models have:

treatment.rb

has_and_belongs_to_many :soa_lines

soa_line.rb

has_and_belongs_to_many :treatments

But when I try to access to treatment.soa_lines it returns nothing:

  test successful treatment modification do
treatment = treatments(:treatment4)

puts Id, treatment.id
puts Code, treatment.code
puts Description, treatment.description
puts Reduction, treatment.reduction
puts Account, treatment.account.name
puts Soa Lines, treatment.soa_lines

All puts return correct values but treatment.soa_lines is []

What I'm doing wrong? What can I check to correct this?

-- 
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 design and write my first blog using RoR?

2011-08-02 Thread Juan Kinunt
IMO you are mixin Rails and Ruby. Rails has one focus on facilitating 
code reuse. In no way Ruby or Rails have invented code reuse. Nobody 
says that.

If you are learning Rails I think you should do what others are saying 
first.

Rubyist Rohit wrote in post #1014431:
 Isn't the concept of Classes mean this? Does Ruby has something more
 advanced?

-- 
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: Problems with fixtures and HABTM

2011-08-02 Thread Juan Kinunt
The problem was that if you want to use the name convention for defining 
relationships like in:

treatments: treatment4

The treatment fixture cannot have an id attribute. Ids should be managed 
by Rails in this case.

-- 
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] Any opensource Learning Management System as Moodle on Rails?

2011-02-14 Thread Juan Kinunt
Any opensource Learning Management System as Moodle on Rails?

Tested CascadeLMS but very focused in university classes.

-- 
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] How do you get realtime visitor stats in RoR?

2010-09-26 Thread Juan Kinunt
I have found some projects as http://www.railstat.com/ but seem not
updated. I have used Google Analytics too, but it is not realtime and it
do not give some important information as IP 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: How do you get realtime visitor stats in RoR?

2010-09-26 Thread Juan Kinunt
Can you share the script that you use to parse the logs?

Norm Scherer wrote:

 I grab them out of the logs using a cron job which mails the results to 
 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] Populate default data in tables when object is created

2010-07-13 Thread Juan Kinunt
Hi,

How can I populate a table (create several default objects) after a
company (an object) is created. I would use after_create inside the
Company model but I need to populate a lot of data and I think the model
is not a good place. I'm thinking about having the data I want to
populate in a yml file and insert it in a table when a company is
created using after_create, but I don't know how to do that. Any hint?
Thanks!
-- 
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 default data in tables when object is created

2010-07-13 Thread Juan Kinunt
Ar Chron wrote:
 Juan Kinunt wrote:
 I would use after_create inside the Company model but I need to populate
 a lot of data and I think the model is not a good place.
 
 Why is that?  It certainly sounds like your creation of a company 
 requires the writing of some additional data, which are effectively 
 default attributes of a company, no?

For example, a Company has_many Threats and a Threat belongs_to a 
Company and I want to populate the table Threats with some default 
threats when a Company is created. I don't use the same threats for each 
company because each company can add, delete and modify their threats as 
they want, so I don't want to share threats. If you think this can be 
done differently better any hint will be really appreciated :)
-- 
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] How to check if an attribute has changed?

2010-06-14 Thread Juan Kinunt
I have read about dirty object but I'm not sure if they are still
present or recommended in Rails.
-- 
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: Update related model after_destroy object

2010-04-18 Thread Juan Kinunt
Viorel wrote:
 I think it is a problem with your model. Tou should not have fields
 with calculated values, only a method that calculate the value, witch
 you call when you need that value

Why can't my model have calculated values? Right know, my problem is 
that I have a lot of virtual attributes in order to calculate these 
values when I need them. I use this attributes a lot (the virtual 
attributes are total and tax of invoices that are calculated from the 
lines of the invoices) and the app have efficienty problems. I use this 
attributes for searching, doing statistics, calculate another 
values...so I have decided to store them in the database. Each time a 
line is created, modified or deleted the corresponding invoice is 
updated. What do you think about this implementation?
-- 
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] Update related model after_destroy object

2010-04-17 Thread Juan Kinunt
Hi!,

I know that Rails do not save in cascade so I need to solve this
problem:
I have invoice that has lines. Invoice have fields that are calculated
with values of lines so when a line is modified or deleted I need to
update the invoice, how I do that automaticaly? If I use before_save on
invoice it does nothing because it does not detect that a line related
is modified. Is the best solution to use a after_save on line that
updates the invoice?
-- 
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] Find efficiently greater string in model attribute

2010-03-29 Thread Juan Kinunt
How can I find efficiently the model Invoice with the greater code
(invoice attribute) when the code is a string like 1/10, 2/10,
3/10 (without quotes) and where only the number before the slash
count? 1/10  2/10  3/10  11/10  12/10, 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: Find efficiently greater string in model attribute

2010-03-29 Thread Juan Kinunt
Now I'm using:

  def after_initialize
if self.new_record? and self.codigo.blank?
  max_codigo = FacturaEmitida.all.map{|f| 
f.codigo.split('/')[0].to_i}.max
  if !max_codigo.nil?
self.codigo = (max_codigo + 
1).to_s+'/'+Date.today.strftime(%y)
  else
self.codigo = 1/+Date.today.strftime(%y)
  end
end
  end

but I think it is very inefficient.
-- 
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] Print a PDF directly after prawnto with iframes

2010-01-02 Thread Juan Kinunt
Hi,

I think I'm very near of accomplishing this but I have a problem.
This is the code:

%- content_for :head do -%
  script type=text/javascript charset=utf-8
function printPDF(){
  var pdf = document.getElementById(pdfDoc).contentWindow;
  pdf.focus();
  pdf.print();
}
  /script
%- end -%

iframe src=/aaa.pdf id=pdfDoc name=pdfDoc/iframe

li%= link_to 'Print', {:controller = 'receipt', :action = 'print',
:id = @receipt.id, :format = 'pdf'}, :target = 'pdfDoc' %/li

And the print action:

  def print
@receipt= Receipt.find(params[:id])
prawnto :inline = true, :filename = receipt...@receipt.codigo}
  end

Now when I click in the link 'Print' the iframe is reloaded with the pdf
generated by prawn but I don't know how to call then the printPDF
javascript function. If I just could call this javascript from the
controller (with ajax) or from the view with javascript after the iframe
is reloaded I would solve my problem.

Any help will be really appreciated!
-- 
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] Retrieving object from a user

2009-10-02 Thread Juan Kinunt

Hi,

I would like which is the best way to implement this:
I have an application with invoices, lines, accouts, etc... lots of
models. Each element of a model belongs to a different user so when a
user is logged he will see only his elements. I can implement this
adding in all the find methods the condition :user_id =
params[:user_id].

But, is there any other way that automatically adds this condition to
all the queries if a user is logged in?
-- 
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] Variables in URLs. Routes manipulation.

2009-08-25 Thread Juan Kinunt

Hi,

I have invoices, each belonging to different fiscal years. When browsing
my app you are navigation seeing information about the current fiscal
year but I would like to allow the users to change to another fiscal
year and browse the same way through old information.
I've been considering storing the fiscal_year in session and use a
default_scope to query for invoices from the fiscal_year the user is
browsing. But someone adviced me to put the fiscal_year variable in the
URL in order to allow navigation in different fiscal_years for one user
at the same time.
How can I implement this feature? The idea is browsing always a URL like

http://localhost:3000/2009/invoices/new or
http://localhost:3000/2009/invoices/search -- http://localhost:3000/%=
session[:fiscal_year] %/controller/action/id

Is it possible? Would it be restful? Where can I find more info about
implementing this? The links will work the same after implementing this
solution? Do you recommend any other solution?

Thanks.
-- 
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] Problems with testing, foxy fixtures and polymorphism

2009-08-16 Thread Juan Kinunt

Hi,

I'm using Rails version 2.3.2 but it seems that my fixtures are wrong
and when testing a relation among two models does not appear. I have no
problems executing the application, only with tests.

These are my fixtures:

/* ingresos.yml */
primero:
  origen: jack (Cliente)
  tipo: Banco
  fecha: 2009-06-05
  cantidad: 10

/* clientes.yml */
jack:
  nombre: Jack Sephard

The error (The error ocurred while evaluating nil.nombre) is in this
line:

/* show.html.erb */
%=h @ingreso.origen_type %: %= @ingreso.origen.nombre %

The models are these:

/* ingreso.rb */
class Ingreso  ActiveRecord::Base
  belongs_to :origen, :polymorphic = true

/* cliente.rb */
class Cliente  ActiveRecord::Base
  has_many :ingresos, :as = :origen
/**/

Any idea will be appreciated. Thanks 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-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] Foxy Fixtures and Polymorphism not running properly

2009-08-15 Thread Juan Kinunt

I would like to hear ideas about a problem I'm having with testing a
controller from a model that uses polimorphism. It seems that the
fixture do not recognize the relationship. Did you see errors in these
files? The error I get is:

/* ERROR */
  1) Error:
test_should_show_ingreso(IngresosControllerTest):
ActionView::TemplateError: You have a nil object when you didn't expect
it!
The error occurred while evaluating nil.nombre
On line #18 of app/views/ingresos/show.html.erb

15:
16: p
17:   bOrigen/b
18:   %=h @ingreso.origen_type %: %= @ingreso.origen.nombre
%
19: /p
20:
21:

app/views/ingresos/show.html.erb:18
app/controllers/ingresos_controller.rb:86:in `show'
/test/functional/ingresos_controller_test.rb:32:in
`test_should_show_ingreso'
c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
c:/ruby/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in
`run_suite'
c:/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in
`start_mediator'
c:/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in
`start'
c:/ruby/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in
`run'
c:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
c:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'
c:/ruby/lib/ruby/1.8/test/unit.rb:278
rake (0.8.7) lib/rake/rake_test_loader.rb:5

/* clientes.yml */
jack:
  NIF: B98654321
  nombre: Jack

/* ingresos.yml */
primero:
  origen: jack (Cliente)

/* cliente.rb */
class Cliente  ActiveRecord::Base
  has_many :ingresos, :as = :origen
end

/* ingreso.rb */
class Ingreso  ActiveRecord::Base
  belongs_to :origen, :polymorphic = true
end

/* test_ingresos_controller.rb */
  test should show ingreso do
get :show, { :id = ingresos(:primero).to_param }, { :usuario_id =
usuarios(:fulanito).id }

assert_response :success
  end

/* views/ingresos/show.html.erb
p
  bOrigen/b
  %=h @ingreso.origen_type %: %= @ingreso.origen.nombre %
/p

Any help will be appreciated. Thanks 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-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] Nested forms, dynamic elements and valid xhtml/DOM ids

2009-07-09 Thread Juan Kinunt

Hi,

I would like to know if anyone has been able to implement correctly 2.3
nested forms and create dynamically (javascript) a bunch of nested
elements with their correct DOM ids.

I've seen Complex forms Railcasts but they use pre-2.3 nested forms.
I've seen Alloy solution but it is not working properly to me. When
creating more than two lines dynamically the id is repeated.
I've seen Zilkey solution but its implemented for pre-2.3 nested forms.

Any idea, help, pointer, blog post, etc... will be really appreciated!!

Thanks!
-- 
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] Problem with 2.3 nested forms and new elements

2009-06-29 Thread Juan Kinunt

Hi,

I'm using the new nested forms functionality and I having problems with
new created elements.

I have an invoice with lines. I would like to be able to create a new
invoice, in the same form insert new lines dinamically and saving the
invoice and the lines when everything is validated, not before.

The problem is that when I add a line dinamically to the form, the new
line created have the same id of other lines and when saving the invoce
only one line with the same id is saved.

Any pointer or pattern to do this different will be really appreciated
because I'm blocked with this right now :(

This is the ids generated in HTML when I add three lines:

table id=lineas
tbodytr
  thArtículo/th
  thUnids./th
  thPrecio/th
  thTotal/th
/tr

tr class=linea

  tdselect id=factura_lineas_attributes_0_articulo_id
name=factura[lineas_attributes][0][articulo_id]option
value=Seleccione un artículo/option
option value=1Bombillas/option
option value=2Cebador/option/select/td
  tdinput id=factura_lineas_attributes_0_unidades
name=factura[lineas_attributes][0][unidades] onkeyup=sayhola(this)
size=30 type=text/td
  tdinput id=factura_lineas_attributes_0_precio
name=factura[lineas_attributes][0][precio] size=30 type=text/td

  tda href=# onclick=$(this).up('.linea').remove(); return
false;remove/a/td

/tr

   /tbodytbodytr class=linea

  tdselect id=factura_lineas_attributes_1_articulo_id
name=factura[lineas_attributes][1][articulo_id]option
value=Seleccione un artículo/option
option value=1Bombillas/option
option value=2Cebador/option/select/td
  tdinput id=factura_lineas_attributes_1_unidades
name=factura[lineas_attributes][1][unidades] onkeyup=sayhola(this)
size=30 type=text/td

  tdinput id=factura_lineas_attributes_1_precio
name=factura[lineas_attributes][1][precio] size=30 type=text/td

  tda href=# onclick=$(this).up('.linea').remove(); return
false;remove/a/td

/tr
/tbodytbodytr class=linea

  tdselect id=factura_lineas_attributes_1_articulo_id
name=factura[lineas_attributes][1][articulo_id]/td

  tdinput id=factura_lineas_attributes_1_unidades
name=factura[lineas_attributes][1][unidades] size=30
type=text/td
  tdinput id=factura_lineas_attributes_1_precio
name=factura[lineas_attributes][1][precio] size=30 type=text/td

  tda href=# onclick=$(this).up('.linea').remove(); return
false;remove/a/td

/tr
/tbody/table

** facturas_controller.rb fragment **
  def new
@factura = Factura.new
@factura.codigo = #{Factura.last.id+1}-#{Date.today.year}
@factura.lineas.build
@clientes = Cliente.find(:all, :order = 'nombre')
@articulos = Articulo.find(:all, :order = 'nombre')

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml = @factura }
end
  end

** facturas_helper.rb fragment 
  def add_linea_link(name, form)
link_to_function name do |page|
  nueva_linea = @factura.lineas.build
  linea = render(:partial = 'linea', :locals = { :pf = form,
:linea = nueva_linea})
  page  %{
 var new_linea_id = new_ + new Date().getTime();
 $('lineas').insert({ bottom: #{ escape_javascript
linea }.replace(/new_\\d+/g, new_linea_id) });
  }
end
  end

** _form.erb.html from facturas fragment **
  table id=lineas
tr
  thArtículo/th
  thUnids./th
  thPrecio/th
  thTotal/th
/tr

%= render :partial = 'linea', :collection = @factura.lineas,
:locals = { :pf = factura_form } %
   /table

  p
%= add_linea_link Añadir linea, factura_form %
  /p

** _linea.erb.rhtml fragment 
tr class=linea
% pf.fields_for :lineas, linea do |linea_form| %
  td%= linea_form.collection_select(:articulo_id, @articulos, :id,
:nombre, {:prompt = 'Seleccione un artículo'}) %/td
  td%= linea_form.text_field :unidades, :onkeyup = sayhola(this)
%/td
  td%= linea_form.text_field :precio %/td
  td id=totalALGO/td
  td%= link_to_function remove, $(this).up('.linea').remove()
%/td
% end %
/tr

Thanks!
-- 
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] Complex forms with correct ids

2009-06-29 Thread Juan Kinunt

Hi,

I would like to know if the last best solution is which is described
here http://zilkey.com/2008/4/5/complex-forms-with-correct-ids or is
there any better/different solution for this problem.

Thanks 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-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: observe_form + call back after page changes - why?

2009-06-02 Thread Juan Kinunt

Same here, I notice the same behaviour, when changing a field a PUT is 
sent, why?

decalod85 wrote:
 On Mar 2, 2:33�pm, David Sousa rails-mailing-l...@andreas-s.net
 wrote:
 Anyone?
 I did not find the solution yet!
 
 Neither did I.  I have a similar problem with observe_form, using it
 for validations.
 
 It fires a PUT for each field change I make, and a POST (to my
 validation controller method) after the changes are submitted to the
 server.

-- 
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] How to test a controller that needs to be logged?

2009-04-28 Thread Juan Kinunt

Hi,

I know that I should use IntegrationTests to test flows of data. For
example, when an action requires various controllers. My question is, if
I can't post to another controller from for example
organizacions_controller_test.rb, how I can test its actions if those
actions require to be logged?

I can't post 'users/login', :user = {...}
I can't post {:controller = 'users', :action='login'}, :user ={...}

etc...

Thanks.
-- 
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] Return to previous page

2009-04-15 Thread Juan Kinunt

Is there a 'rails way' to allow easy navigation to the previous page or
should we use parameters and 'ifs'?
I'm talking about, for example, a 'Back' button that links to differente
pages depending the previous page.
Thanks.
-- 
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] Inheritance vs Polymorphism: Design Question for IS A

2009-04-01 Thread Juan Kinunt

Hi!

I have the next abstract composition:

Organization
ConsultingFirm IS A Organization
Client IS A Organization

User
ConsultingFirmUser IS A User
ClientUser IS A User

ConsultingFirmUser BELONGS TO ConsultingFirm
ClientUser BELONGS TO Client

ConsultingFirm HAS MANY ConsultingFirmUsers
Client HAS MANY ClientUsers

I don't know how is the best way of implementing the IS A relationship
in Rails. What would you use? Inheritance or Polymorphism?

Thanks!
-- 
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] Sending multiple checkboxes values clicking a link

2009-03-07 Thread Juan Kinunt

Hi,
I have multiple checkboxes in a table each one representing an item.
They are like this:

[...]
td%= check_box incidencias_ids, incidencia.id %/td
td%=h incidencia.cliente.nombre %/td
[...]

In the controller I have:

incidencias_ids = params[:incidencias_ids]
@incidencias = []
for id in incidencias_ids
  @incidencias  Incidencia.find_by_id(id)
end

I think this is enough to send all the checked checkboxes and manipulate
them.
But I don't know how to send all the checkboxes to the controller! I
know how to do it with link_to_remote but the answer is not displayed...

How I can do this with link_to? Another way?
-- 
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] link_to_remote and open new window passing parameters

2009-03-05 Thread Juan Kinunt

Hi,
I would like to implement this:
I have a view that shows a list of elements. Each element have a
checkbox. The user can select some events marking the checkbox and click
the link_to_remote Print this elements. When this link is clicked
another window is open with only the selected events and is printed (ala
Google Maps).

I have coded the selection of items and I'm able to open a new window. I
use the link_to_remote like this:

%= link_to_remote 'Imprimir incidencias marcadas',
{ :url = '/incidencias/popup',
  :submit = 'table'
} %

The elements are submited properly. I know how to open the new window:

popup.rjs:

page  window.open('/events/print', 'print',
'left=20,top=20,width=500,height=500,toolbar=1,resizable=0' );

But I don't know how to pass the list of elements from popup.rjs to
/events/print in the new window!!

Any idea will be appreciated.
-- 
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] Separate rows in view depending its date

2009-03-04 Thread Juan Kinunt

Hi,

I would like to hear your opinions about how do you think I can
implement this.
I have a @events array where I have events each one with its datetime,
and ordered by it.
I would like to show a list of these events in a table. I would like to
put a blank row in the table after each group of events with the same
date.
I don't know if it is better to separate the events in groups in the
controller or if I can use an 'if' in the view to insert this blank row.

Thanks.
-- 
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: Separate rows in view depending its date

2009-03-04 Thread Juan Kinunt

What I do not see is how to build those 'date-groups' because what I 
have now is only @events = Event.find(:all, :order = 'date')

In the view I do:

%= for event in @events %
[...]

bill walton wrote:

 CSS.  Wrap each date-group in a div class='whatever' and style it with
 a top/bottom margin to get the spacing you're looking for.

-- 
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] datetime_select field order and month list

2009-02-04 Thread Juan Kinunt

Hi!

I've searched throw Google and this forum and I found some answers and
some tickets but I would like to know the actual situation. I've seen
solutions for date_select but not for datetime_select.

First: Is it possible to specify a list of months to be used in
datetime_select? I want to translate the month names to other language
and I would prefer not to use one of those localization plugins by now.

Second: Is it possible to change the field order of the day, month, etc
in the datetime_select helper?

Thanks.
-- 
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] Fixed set of values for an attribute and migrations

2009-02-03 Thread Juan Kinunt

Hi,
I have a model with three attributes that could be a fixed set of
different values. Each attribute does not have sufficient entity to be a
class (in my opinion) and I prefer to not to create classes in order to
store them.
For example, one attribute can be only three strings: phone, email or
fax.
The second, two strings: building or garage.
The correct way of doing this is restricting to this values in the
model?
Is there something I can/have to do in the migration?
I'm thinking about a validation of each field in the model and a
selection-option field in the forms. Is this the best pattern in order
to implement this? Would you prefer to create models for each of this
attributes?
Hope I explained myself properly.
Thanks.
-- 
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
-~--~~~~--~~--~--~---