1) I wanted to know how can i use Active Scaffold only for list
(index) view ? It means that i will use my own views and methods for
create create and update, and use Active Scaffold for the list view?
I have tried to remove the index method in my controller, but i still
have anything on my list view...
2) Do you know how can i remove/desable the "Add Existing" link when
nesting associated models in create and update view?
3) I have a "filename" column for file upload. I use Active scaffold
in this controller. When i am in the create view, the file upload
column works fine. But when i am in the edit/update view the
"filename" column became a simple text field column instead of a file
upload column. Can you help me to solve thoses problems
Thanks for your help and answers.
I only want to disable the "add existing link", not to replace it.
Thanks.
On 22 fév, 15:14, kenny.ortm...@gmail.com wrote:
> I think all you need to do for #1 is config.actions.exclude = [:create, :update, :delete]
>
> This syntax should be on the wikihttp://github.com/activescaffold/active_scaffoldthen click wiki
Add existing in subforms is shown when there are records to add. If you are
editing/creating a record with a has_many/has_one association you won't get
add existing if you don't have orphaned records.
A way to force disabling add existing is overriding
options_for_association_count in your helper:
def options_for_association_count(association)
if association.name == :association_name_to_disable
0
else
super
end
end
>
> On Mon, Feb 22, 2010 at 7:47 AM, gs84 <salim...@gmail.com> wrote:
> > Hi every body,
> >
> >
> > 2) Do you know how can i remove/desable the "Add Existing" link when
> > nesting associated models in create and update view?
> >
> >
> > 3) I have a "filename" column for file upload. I use Active scaffold
> > in this controller. When i am in the create view, the file upload
> > column works fine. But when i am in the edit/update view the
> > "filename" column became a simple text field column instead of a file
> > upload column. Can you help me to solve thoses problems
> >
> >
> > Thanks for your help and answers.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ActiveScaffold : Ruby on Rails plugin" group.
> > To post to this group, send email to actives...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > activescaffol...@googlegroups.com<activescaffold%2Bunsubscribe@
> >googlegroups.com> .
> > For more options, visit this group at
> > http://groups.google.com/group/activescaffold?hl=en.
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) ser...@entrecables.com
On 22 fév, 20:14, Kenneth Ortmann <kenny.ortm...@gmail.com> wrote:
> for the third issue Can you show your controller?
>
> I'm not sure about #2 sergio may have more input on this.
This is my "Offreservices" controller as you asked me for the third
issue: The associated column that has the file upload column is
"pjoffreservices".
So the file upload works well in the pjoffreservices controller views,
but not in "offreservices" views in which it is an associated column.
class OffreservicesController < ApplicationController
before_filter :login_required, :only => [:create, :update]
before_filter :check_for_entiteservice, :only => [:create, :update]
#before_filter :update_config
active_scaffold :offreservice do |config|
config.create.multipart = true
config.update.multipart = true
#config.theme = :blue #gestion de la couleur des entetes
config.columns =
[:nomDescriptif, :entiteservices, :services, :prices, :communes, :horaires, :pjoffreservices]
config.list.columns =
[:nomDescriptif, :entiteservices, :services, :horaires]
config.list.per_page = 15
#les 2 lignes suivantes permettent de n'afficher qu'un bouton
Nouveau pour les association
config.columns[:horaires].show_blank_record = false
config.columns[:pjoffreservices].show_blank_record = false
config.create.columns.exclude(:user, :commentaires)
config.update.columns.exclude(:user, :commentaires)
config.create.link.inline = false
config.create.multipart = true
config.update.multipart = true
config.list.label = "Offres de services"
config.create.label = "Nouvelle offre de service"
config.show.label = "Fiche offre de service"
#Voir la liste des commentaires pour chaque offre de services
config.nested.add_link("Commentaires", [:commentaires])
config.nested.add_link("Pièces jointes", [:pjoffreservices])
config.update.link.inline = false
#list.sorting = {:organisation => 'ASC'}
config.columns[:entiteservices].search_sql =
'entiteservices.nomEntite'
config.columns[:services].search_sql = 'services.libService'
config.columns[:communes].search_sql = 'communes.ville'
config.columns[:prices].search_sql = 'prices.libPrice'
config.search.columns << :entiteservices
config.search.columns << :services
config.search.columns << :communes
config.search.columns << :prices
config.columns[:entiteservices].form_ui = :select
config.columns[:services].form_ui = :select
config.columns[:communes].form_ui = :select
config.columns[:prices].form_ui = :select
columns[:nomDescriptif].label = "Intitulé:"
columns[:entiteservices].label = "Agence/boutique:"
columns[:services].label = "Nature des services:"
columns[:communes].label = "Communes desservies:"
columns[:pjoffreservices].label = "Pièces jointes:"
columns[:prices].label = "Prix pratiqués:"
end
end #end de la fin du controller
2) Also for the first issue, i add the following:
"config.actions.exclude = [:create, :update, :delete] "
in my controller, but it still no showing my list view.
Thanks.
This is my controller as you asked me for the third issue. The
associated column that has the file upload column is
"pjoffreservices". The file upload works well in "pjoffreservices
controller" views, but not in "offreservices controller" views in
3) For the first issue i add the following: "config.actions.exclude =
[:create, :update, :delete] "
in my controller like this:
class UsersController < ApplicationController
active_scaffold :user do |config|
config.actions.exclude :create, :update, :delete
config.list.columns = [:nom, :prenom, :dateNaissance]
end
end
but i still have nothing in my list/index view. In my controller i
also have show, edit, destroy method. But i have removed the "index"
method for the list view, because it is the only action that i want to
get with Active Scaffold.
2) I override the options_for_association_count in my helper as Sergio
told me, i still have the "add existing" in views ==> no change.
> I'm not sure about #2 sergio may have more input on this.
Add existing in subforms is shown when there are records to add. If
you are
editing/creating a record with a has_many/has_one association you
won't get
add existing if you don't have orphaned records.
A way to force disabling add existing is overriding
options_for_association_count in your helper:
def options_for_association_count(association)
if association.name == :association_name_to_disable
0
else
super
end
end
Thanks.
On 23 fév, 12:27, "Sergio Cambra .:: entreCables S.L. ::."
This is my controller as you asked me for the third issue. The
> I'm not sure about #2 sergio may have more input on this.
Add existing in subforms is shown when there are records to add. If
you are
editing/creating a record with a has_many/has_one association you
won't get
add existing if you don't have orphaned records.
A way to force disabling add existing is overriding
options_for_association_count in your helper:
def options_for_association_count(association)
if association.name == :association_name_to_disable
0
else
super
end
end
Thanks.
On 22 fév, 20:14, Kenneth Ortmann <kenny.ortm...@gmail.com> wrote:
> for the third issue Can you show your controller?
>
> I'm not sure about #2 sergio may have more input on this.
This is my "Offreservices" controller as you asked me for the third
issue: The associated column that has the file upload column is
"pjoffreservices".
So the file upload works well in the pjoffreservices controller views,
but not in "offreservices" views in which it is an associated column.
2) Also for the first issue, i add the following:
"config.actions.exclude = [:create, :update, :delete] "
On 22 fév, 20:14, Kenneth Ortmann <kenny.ortm...@gmail.com> wrote:
> for the third issue Can you show your controller?
>
> I'm not sure about #2 sergio may have more input on this.
Then we need pjoffreservices controller code. Are you using a virtual column
for file upload? Do you have that column in config.subform.columns?
> 3) For the first issue i add the following: "config.actions.exclude =
> [:create, :update, :delete] "
> in my controller like this:
> class UsersController < ApplicationController
>
> active_scaffold :user do |config|
> config.actions.exclude :create, :update, :delete
> config.list.columns = [:nom, :prenom, :dateNaissance]
> end
> end
>
> but i still have nothing in my list/index view. In my controller i
> also have show, edit, destroy method. But i have removed the "index"
> method for the list view, because it is the only action that i want to
> get with Active Scaffold.
Check templates rendered in your log file.
You should get:
Rendering template within layouts/....
Rendering list
Rendered _list_header
....
Rendered _list
Completed in ...
You should exclude show too if you have your own show method. Anyway if you
put active_scaffold block before your methods, active_scaffold methods will be
overrided by your methods.
>
>
> 2) I override the options_for_association_count in my helper as Sergio
> told me, i still have the "add existing" in views ==> no change.
Which helper have you added it in?
I have tried it here and it works. I have a Team model with a has_one :user, I
have some users without team, so they are shown in add existing select. The
controller is Admin::TeamsController, adding that helper to Admin::TeamsHelper
(and checking association.name against :user) removes the add existing option
for user association.
>
> > I'm not sure about #2 sergio may have more input on this.
>
> Add existing in subforms is shown when there are records to add. If
> you are
> editing/creating a record with a has_many/has_one association you
> won't get
> add existing if you don't have orphaned records.
>
> A way to force disabling add existing is overriding
> options_for_association_count in your helper:
> def options_for_association_count(association)
> if association.name == :association_name_to_disable
> 0
> else
> super
> end
> end
--
> for file upload? Do you have that column in config.subform.columns?
I had in config.columns. But i have tried to add it in
config.subform.columns after your post, but it doesn't have any
change.
> Then we need pjoffreservices controller code. Are you using a virtual column
Here is my "pjoffreservices controller":
class PjoffreservicesController < ApplicationController
before_filter :login_required, :only => [:create, :update]
active_scaffold :pjoffreservice do |config|
config.create.multipart = true
config.update.multipart = true
#config.create.formats << :pdf
config.create.columns = [:typepj, :description, :filename]
config.update.columns = [:typepj, :description, :filename]
config.list.columns = [:auteur, :typepj, :description, :filename]
config.create.columns.exclude(:user, :auteur, :created_at, :updated_at)
config.update.columns.exclude(:user, :auteur, :created_at, :updated_at)
config.columns[:typepj].form_ui = :select
config.list.label = "Pièces jointes"
config.columns[:filename].label = "Fichier"
config.columns[:auteur].label = "Auteur"
config.columns[:typepj].label = "Type"
config.columns[:created_at].label = "Créé le"
config.columns[:updated_at].label = "Mis à jour le"
#config.update.link.inline = false
end
end
> Which helper have you added it in?
I in pjoffreservices Helper. And in "offreservices Helper" because
the first one didn't work.
I have a "has_and_belongs_to_many" association.
On 23 fév, 17:18, "Sergio Cambra .:: entreCables S.L. ::."
<ser...@entrecables.com> wrote:
> On Martes, 23 de Febrero de 2010 15:55:11 gs84 escribió:
>
>
> > 3) For the first issue i add the following: "config.actions.exclude =
> > [:create, :update, :delete] "
> > in my controller like this:
> > class UsersController < ApplicationController
>
> > active_scaffold :user do |config|
> > config.actions.exclude :create, :update, :delete
> > config.list.columns = [:nom, :prenom, :dateNaissance]
> > end
> > end
>
> > but i still have nothing in my list/index view. In my controller i
> > also have show, edit, destroy method. But i have removed the "index"
> > method for the list view, because it is the only action that i want to
> > get with Active Scaffold.
>
> Check templates rendered in your log file.
> You should get:
> Rendering template within layouts/....
> Rendering list
> Rendered _list_header
> ....
> Rendered _list
> Completed in ...
>
I only have those two line when trying to show my list in usagers/
index:
Here is my templates rendered in log file:
Processing UsagersController#index (for 127.0.0.1 at 2010-02-23
18:12:30) [GET]
...
Rendering template within layouts/application
Rendering usagers/index
Rendered widgets/_application_navigation (16.0ms)
So i don't have any template rendered that refers to Active scaffold.
Thanks.
This is my controller as you asked me for the third issue. The
associated column that has the file upload column is
"pjoffreservices". The file upload works well in "pjoffreservices
controller" views, but not in "offreservices controller" views in
which it is an associated column.
class OffreservicesController < ApplicationController
before_filter :login_required, :only => [:create, :update]
before_filter :check_for_entiteservice, :only => [:create, :update]
#before_filter :update_config
active_scaffold :offreservice do |config|
config.create.multipart = true
config.update.multipart = true
#config.theme = :blue #gestion de la couleur des entetes
config.columns =
[:nomDescriptif, :entiteservices, :services, :prices, :communes, :horaires, :pjoffreservices]
config.list.columns =
[:nomDescriptif, :entiteservices, :services, :horaires]
config.list.per_page = 15
#les 2 lignes suivantes permettent de n'afficher qu'un bouton
Nouveau pour les association
config.columns[:horaires].show_blank_record = false
config.columns[:pjoffreservices].show_blank_record = false
config.create.columns.exclude(:user, :commentaires)
config.update.columns.exclude(:user, :commentaires)
config.create.link.inline = false
config.create.multipart = true
config.update.multipart = true
config.list.label = "Offres de services"
3) For the first issue i add the following: "config.actions.exclude =
[:create, :update, :delete] "
in my controller like this:
class UsersController < ApplicationController
active_scaffold :user do |config|
config.actions.exclude :create, :update, :delete
config.list.columns = [:nom, :prenom, :dateNaissance]
end
end
but i still have nothing in my list/index view. In my controller i
also have show, edit, destroy method. But i have removed the "index"
method for the list view, because it is the only action that i want to
get with Active Scaffold.
2) I override the options_for_association_count in my helper as Sergio
told me, i still have the "add existing" in views ==> no change.
> I'm not sure about #2 sergio may have more input on this.
Add existing in subforms is shown when there are records to add. If
you are
editing/creating a record with a has_many/has_one association you
won't get
add existing if you don't have orphaned records.
A way to force disabling add existing is overriding
options_for_association_count in your helper:
def options_for_association_count(association)
if association.name == :association_name_to_disable
0
else
super
end
end
Thanks.
On 22 fév, 20:14, Kenneth Ortmann <kenny.ortm...@gmail.com> wrote:
> for the third issue Can you show your controller?
>
> I'm not sure about #2 sergio may have more input on this.
This is my "Offreservices" controller as you asked me for the third
issue: The associated column that has the file upload column is
"pjoffreservices".
So the file upload works well in the pjoffreservices controller views,
but not in "offreservices" views in which it is an associated column.
2) Also for the first issue, i add the following:
"config.actions.exclude = [:create, :update, :delete] "
Have you overrided index or list method? Have you overrided
list_respond_to_html method?
--
Sergio Cambra .:: entreCables S.L. ::.
How are you showing filename column as a file input? Do you have a helper? To
use a helper for a subform you must put it in main controller helper, instead
of helper from subform controller. If you have a helper for filename column in
pjoffreservices helper, you can add that helper to offreservices controller
(helper :pjoffreservices)
>
> > Which helper have you added it in?
>
> I in pjoffreservices Helper. And in "offreservices Helper" because
> the first one didn't work.
> I have a "has_and_belongs_to_many" association.
Returning 0 works for all kind of associations. This is the code from
_form_association_footer.html.erb:
show_add_existing = (!column.through_association? and
options_for_association_count(column.association) > 0)
returning 0 in options_for_association_count sets show_add_existing to false,
and then code which adds select and add existing button is skipped.
Are you sure your helper override is being used? You can try debugging from
that line in form_association_footer, or writing to log file from your helper
(for example Rails.logger.debug association.name.inspect)
--
Sergio Cambra .:: entreCables S.L. ::.
> How are you showing filename column as a file input? Do you have a helper? To
> use a helper for a subform you must put it in main controller helper, instead
> of helper from subform controller. If you have a helper for filename column in
> pjoffreservices helper, you can add that helper to offreservices controller
> (helper :pjoffreservices)
Thanks, this issue is fixed by adding the "filename_form_column" in
offreservices controller view. It did not work because i only added it
in the pjoffreservices controller view.
> returning 0 in options_for_association_count sets show_add_existing to false,
> and then code which adds select and add existing button is skipped.
>
> Are you sure your helper override is being used? You can try debugging from
> that line in form_association_footer, or writing to log file from your helper
> (for example Rails.logger.debug association.name.inspect)
>
Here is my "offreservices Helper":
module OffreservicesHelper
def user_form_column(record, input_name)
if current_user != false
@user = current_user
"#{@user.login}"
end
end
def options_for_association_count(association)
if association.name == :association_name_to_disable
0
else
super
end
end
end
Tell me if there is something wrong in it.
1) I wanted to know how can i use Active Scaffold only for list
(index) view ? It means that i will use my own views and methods
for
create create and update, and use Active Scaffold for the list
view?
For the first issue, i still not get it works. I clear all code in my
index view and delete "index" method in my controller but when trying
to render my list view i get blank page.
I wanted to know if it is possible to use another controller base on
the same model, in which i will redirect show, update, and delete
action to my first controller methods?
I mean, how can i tell Active Scaffold that for the 2nd controller
actions and views (unless for list), it must redirect to the 1st
controller actions and views?
Thanks again.
Yes, you must change :association_name_to_disable with your association name,
I don't know which association you want to disable add existing for
>
> 1) I wanted to know how can i use Active Scaffold only for list
> (index) view ? It means that i will use my own views and methods
> for
> create create and update, and use Active Scaffold for the list
> view?
>
> For the first issue, i still not get it works. I clear all code in my
> index view and delete "index" method in my controller but when trying
> to render my list view i get blank page.
Post full controller, please
>
> I wanted to know if it is possible to use another controller base on
> the same model, in which i will redirect show, update, and delete
> action to my first controller methods?
> I mean, how can i tell Active Scaffold that for the 2nd controller
> actions and views (unless for list), it must redirect to the 1st
> controller actions and views?
If I understand you right, you can set controller for links with
config.create.link.controller, config.update.link.controller,
config.show.link.controller, config.delete.link.controller
>
> Thanks again.
--
Sergio Cambra .:: entreCables S.L. ::.
On 24 fév, 18:07, "Sergio Cambra .:: entreCables S.L. ::."
<ser...@entrecables.com> wrote:
> On Miércoles, 24 de Febrero de 2010 16:02:12 gs84 escribió:
> > Tell me if there is something wrong in it.
>
> Yes, you must change :association_name_to_disable with your association name,
> I don't know which association you want to disable add existing for
Thanks, this solve my problem.
>
> > I wanted to know if it is possible to use another controller base on
> > the same model, in which i will redirect show, update, and delete
> > action to my first controller methods?
> > I mean, how can i tell Active Scaffold that for the 2nd controller
> > actions and views (unless for list), it must redirect to the 1st
> > controller actions and views?
>
> If I understand you right, you can set controller for links with
> config.create.link.controller, config.update.link.controller,
> config.show.link.controller, config.delete.link.controller
This is what i were looking for. Thaks again to all of you.
I think you can close this topic.