I'd like to add some custom code to the destroy and edit default actions in active admin. Essentially, when I edit or delete a member, I want to sync that action with a copy on an external database.
I could either do a redirect to a custom method to do that then redirect back to the index, or create my own action in place of the default actions I could call.
Is there a better way to do this? preferably by just modifying the active admin destroy and edit functions?
Customize controller answer on Stack Overflow
The example overrides create, but you can do the same with update and destroy.
Related
I'am writing a web app for personal use with Yesod. I don't want authentication and no log in.
What is the best way to achieve this?
remove the Auth library from the application
use a default hidden user that automatically logs in at startup (Auth.dummy?)
or something else....
Assuming you're using a recent version of the scaffolded site, you should be able to look in src/Foundation.hs for the definition of isAuthorized. Replace the entire definition with:
isAuthorized _ _ = return Authorized
or even remove it entirely, since the above definition is the default.
That should be sufficient to allow access to all pages. Next, search your code for uses of maybeAuth* and requireAuth* functions. Make sure that pages that use maybeAuth* work as expected if they get back Nothing. Remove any uses of requireAuth* and any dependencies on its return value.
Afterwards, you can clean up unneeded code, but this is entirely optional:
In Foundation.hs, you can:
remove Yesod.Auth.Dummy and Yesod.Auth.OpenId imports
remove the definition of muser <- maybeAuthPair from defaultLayout
remove login/logout/profile pages from the navbar (menuItems)
remove the authRoute definition in the instance Yesod App
remove AuthR and ProfileR from the breadcrumb
remove the instance YesodAuth App, the definition of isAuthenticated, and the instance YesodAuthPersist App
In NoFoundation.hs, you can remove the Yesod.Auth import.
In Settings.hs, remove the appAuthDummyLogin field and the reference to it in instance FromJSON AppSettings
In config/routes.yesodroutes remove /auth and /profile routes
Remove src/Handler/Profile.hs and the import Handler.Profile from Application.hs.
Stamp out any remaining references to maybeAuth* functions or references to the ProfileR route.
In my MVC application, I dont want any user to type in the address bar of the browser and navigate to any controller action directly.Can I enable this for the whole application?if yes ,How? Can you please let me know the concept name ?
Also I dont want to do that through Request.URLReferrer because it has its own security risks (per Avoiding user to navigate to a view by entering url in the browser)
Thanks in advance!
You need to use Custom Action Filter Attributes, See :
http://www.asp.net/mvc/tutorials/hands-on-labs/aspnet-mvc-4-custom-action-filters
****Updated:**
As Parsanna mentioned in comment,
You can use the [ChildActionOnly] attribute on your action method to make sure it's not called directly, or use the ControllerContext.IsChildAction property inside your action to determine if you want to redirect.
See :Asp.net mvc How to prevent browser from calling an action method?
I am writing a plugin for Jive (SBS) 7 and want to add more data to the template for the user profile Overview page (i.e. /people/admin ). In Jive 6 I did overwrite the profile path in struts and added my own ViewProfile action. But this action seems to be called no more.
I also cannot even figure out where the templates I changed get their data from (soy/people/profile/{userProfile, header, head}.soy) or what action is responsible for.
So how can I add another property to the soy file that gets a custom property for the targetUser? (custom property = property saved in the database table jiveuserprop)
You need to create a plugin and then use the option. Then, you simply use jquery to add the extra stuff.
you can create an action that takes in information using getters or post and throw it into the user's extended properties. You can create another action that'll retrieve that info in json.
then, simply use jquery's getJson to grab the info and use selectors to show the data in the user profile.
Don't forget to use the $j(document).ready(function(){ // your code here }); to show the info
simple example:
<scipt>
$j(document).ready(function(){
$j("div#j-profile-header-details").append("<p>hello World</p>");
});
</script>
will append "hello world" under the user's email address / job title.
hope this helps. feel free to ask more questions if it doesn't make sense. here's a good link on writing the javascript part of the plugin: http://docs.jivesoftware.com/jive/7.0/community_admin/index.jsp?topic=/com.jivesoftware.help.sbs.online/developer/PluginXMLReference.html
I got an answer in the Jive Developer community:
profile is an action in Struts2. /people/username is a URL Mapper permutation
https://community.jivesoftware.com/thread/263660
I am working on a rails app, and have generated a Controller via
rails g controller Pics index upload
but now I would like to add another action
delete
do I do this by manually adding a delete method in the Pics controller?
Or do I need to run another generation. My concern is that by adding manually something may not get included (not sure what it would be, but something under the hood.)
Is this the best way of adding a new action to a generated controller?
If you add manually, just make sure you have the right route on your routes.rb.
Let's say you create your delete action inside your Pics controller.
def delete
# do stuff
end
On your routes.rb, you need to append the route to your resource like this, remembering to analyse if it is a resource that acts upon a member of your resource, or a collection. (More about this you can read on this guide http://guides.rubyonrails.org/routing.html#adding-more-restful-actions).
resource :pics do
collection do
post :delete
end
end
Or
resource :pics do
member do
post :delete
end
end
Remember that all RESTFUL actions are handled by default by the rails router, again, try to read the guide i showed earlier for precise information about the topic. Hope it helps.
The active admin page should load the singleton instance of the model (I am using an ActiveRecord compliant model). I'm not sure where to put the code to load the single instance of the model, or how to make the default page for the record be an edit page rather than the collection page.
You should check http://activeadmin.info/docs/8-custom-actions.html#member_actions, and, you can set the actions to:
actions :update
In the member action you can focus to update the instance.
--
Hi again, today I did something like that, simpler, and this is what I did:
Make the index look like a blog http://activeadmin.info/docs/3-index-pages/index-as-blog.html
Only use actions: index, edit, update
Use a scope http://activeadmin.info/docs/2-resource-customization.html#scoping_the_queries (also, you can use only scope and not scope_to if you want to call a scope from the model).
Hope it helps.