Retrieve a list of all puppetclasses using the REST Api
When playing aroung with the rest api I missed the feature to retrieve a list of all puppetclasses with their respective ids.
So, I alter the file app/controllers/puppetclasses_controller.rb to include a method to retrieve a json object with all classes with their ids.
@puppetclasses = Puppetclass.find(:all, :select => "id, name", :order => 'id').to_json
render :json => @puppetclasses
Then, in the router.rb file I add:
map.connect "/puppetclasses/all", :controller => 'puppetclasses', :action => 'all'
I am not a big ruby expert, so I don't know if this is the best approach... :)
#2 Updated by Gustavo Soares over 9 years ago
Ohad Levy wrote:
look for the format_for for examples
Take a look at this patch: http://github.com/gustavosoares/foreman/commit/daf07f29b9559f239c6de4ca877e6d7cdeb744b4