Hi Ronny,
What do you mean with "I am not able to make the model editable"? Does
the form appear? It it does, what happens after you submit it? What does
the log say?
On the other hand, I've never used RailsSettings, so I don't know how it
works. When I need to save application settings, I usually create a
model called "options", with two fields "key" and "value" (hobo g
resource option key:string value:string). Then I can do:
Options.find_by_key("whatever")
And I have the standard Hobo CRUD interface in /options.
Regards,
Ignacio
El 20/05/13 19:53, Ronny Hanssen escribió:
Hi all,
Long time since I had any time to do Hobo related work. Nice to see how
this moves on. I am on Hobo 1.3, but I am hoping to move to 2.0 in not
too long.
I am changing a current 1.3 app where I want to make some application
settings available. To do this I am trying to use
the RailsSettings::CachedSettings project
(https://github.com/huacnlee/rails-settings-cached). It kinda works very
well.
*The problem appears when I try to setup a user interface for changing
the settings. I can list the index page, I can show the fields, but I am
not able to make the model editable, no matter what i try. Anyone have a
clue on why?*
Inspecting the generated form shows this:
<def tag="form" for="Setting">
<form merge param="default">
<error-messages param/>
<field-list fields="" param/>
<div param="actions">
<submit label="#{ht 'setting.actions.save',
:default=>['Save']}" param/><or-cancel param="cancel"/>
</div>
</form>
</def>
Other than that, the edit-page looks like this:
<def tag="edit-page" for="Setting">
<page merge title="#{ht 'setting.edit.title', :default=>['Edit
Setting'], :name => name(:no_wrapper => true) }">
<body: class="edit-page setting" param/>
<content:>
<section param="content-header">
<h2 param="heading">
<ht key="setting.edit.heading" name="#{name(:no_wrapper
=> true)}">
Edit Setting
</ht>
</h2>
<delete-button label="#{ht 'setting.actions.delete',
:default=>['Remove This Setting']}" param/>
</section>
<section param="content-body">
<form param/>
</section>
</content:>
</page>
</def>
The controller is quite standard for a subsite controller.
class Admin::SettingsController < Admin::AdminSiteController
hobo_model_controller
auto_actions :all, :except => [:new, :create, :destroy]
end
The model looks like this:
class Setting < RailsSettings::CachedSettings
hobo_model # Don't put anything above this
fields do
var :string, :null => false, :name => true
value :text, :primary_content => true
thing_id :integer
thing_type :string, :limit => 30
timestamps
end
never_show :thing_id, :thing_type
# --- Permissions --- #
def create_permitted?
false
end
def update_permitted?
acting_user.administrator?
end
def destroy_permitted?
false
end
def view_permitted?(field)
true
end
end
--
You received this message because you are subscribed to the Google
Groups "Hobo Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
Ignacio Huerta Arteche
http://www.ihuerta.net
Teléfono: 0034 645 70 77 35
Email realizado con software libre
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.