DanielsV
DanielsV

Reputation: 892

Rails controller initiate others controller create action

I need to make new Footprint on every action user makes in database. How can I initiate Footprint.new() on other controller also giving automatic statement with it.

For example when User deletes entity.

entity_controller action delete will pass such statement as "user"+ "{ @user.name }" + "deleted entity "{ @entity.name }" to footprint.description.

Also it should pass current user id to footprint.user_id

Don't know how to do it!

Upvotes: 2

Views: 60

Answers (2)

webster
webster

Reputation: 4012

I guess you need a user activity feed on your application. You can make use of the Public Activity gem for achieving this functionality. There is also a nice Railscast about the gem.

Upvotes: 0

Mani
Mani

Reputation: 2563

I was not clear on your question , but what i felt was that you want to delete an entity and then wanna pass deleted entity name to another action which is , in some other controller .

def delete
  entity = Entity.find(params[:id]
  entity_name = entity.name
  entity.destroy!
  footprint_path(entity_name)
end
you can use path helpers when you have defined resources in your routes.rb , which in this case is , resource "footprint"

Update To track user's activity you can use paper_trail or Userstamping

Upvotes: 0

Related Questions