Rails create static page from dynamic page - ruby-on-rails-3

This seems like it should not be that hard but I am trying to figure out how to create a 'snapshot' or 'locked' view from one on my views. This view currently is dynamic but I want to lock it so that any changes I make will not propagate until I want them too.
This would be a front facing page that should not get updated until I choose to update it such as by timestamping a field like updated_lock or something to that effect.
Any ideas?
Thanks,
BR

You might try caches_action in your controller. It will create the static version and save it. You could either create it in dev and checkin, or have it generated in production. You'd need to fine a way to delete it in production if it's not checked in. Requires caching to be turned on.
If you are OK with checking it in - you can always save from the browser.
Basically - if there is a file in public at the same location as the view, it will be served instead of the dynamic one.

Related

How to track when a user views a JIRA issue

In my plugin I need to track when a user views an issue using UI. Ideally I'd like to know if it was opened directly, or was viewed in Issue Navigator Detail View. I need to track who and when viewed an issue.
What's the best way to do this?
Cheers,
Oles
The most straightforward way would be to use a Servlet Filter plugin module and scan the requested URL for those corresponding to issue views. You can generally distinguish between viewing the issue directly and a view from within the Issue Navigator by examining the query parameters.
Alternatively, you could also build a Web Panel plugin module that renders no significant UI, but which would always be invoked when an issue is viewed. You'd probably want to position the web-panel on the right side of the issue view with atl.jira.view.issue.right.context.
In either scenario above, you can fetch the current user from an injected JiraAuthenticationContext.

What is it? [[++[[*context_key]].yaKey]] (ModX)

I need to change value of SEO-goals (onclick) on the multi domain website. And I found this thing on the project server(MODX): onclick="yaCounter[[++[[*context_key]].yaKey]].reachGoal('something'); return true;" And if I change this text it changes everÿwhere. What is the best solution to make it works?
[[++[[*context_key]].yaKey]] - this is tricky solution for multidomain sites. First modx set [[*context_key]] and for web context this means you get - [[++web.yaKey]], and then modx get web.yaKey system setting and set it to the page. So - you need to create system setting for every context with the name "context_key.yaKey".

Yii Problems With The Testdrive Example

I'm trying to create my first Yii application, step by step, with the testdrive example but I meet some problems.
When I try to create a new user, I obtain an error CException:
UserController cannot find the requested view "_form".
If I understand you correctly, you've created a protected/controller/UserController.php.
From the sounds of it, somewhere in that code you have a call to render (or partialRender), that looks something like this:
$this->render('_form');
For this to work, you'll need a corresponding view file. Views should go in protected/views/<controllerName> and should be files that correspond to the view name you use. In your case, you'll need a protected/views/User/_form.php.

Would like to add some custom ajax & javascript to activeadmin based application

Hi guys I'm working on this application using activeadmin. I've come to a point where I would like to add in some ajax based functions. I have the basic form set up using teh activeadmin resource and it generates a very pretty form.
I would like to while the user is entering the details on the form - run a ajax call which would retrieve some html based on the values being entered and populate it on the page.
More likely I would like a way to add custom javascript to the page. Whats the best way to do this - I'm facing issues with returning html without the entire activeadmin layout coming with it.
You can use the /config/initializers/active_admin.rb
You can add javascript resources like this:
config.register_javascript 'my_functions.js'
I use to put code directly to /app/assets/javascripts/active_admin.js
You can also include script in /config/initializers/active_admin.rb

ruby on rails 3, render multiple views in one view

I have a problem and I dont know how to solve it.
I have a user that log in a web site, and I identify them by session[:user_id] and user has a status page that is defined in user_controller and in status view.
So, I would like to make one page for admin, to see all the statuses from all users on one page, using already written controller and view.
Is that possible?
I could rewrite some of the code, so that I could call with params, like ?user_id=70 and then set session[:user_id]=params[:user_id], but it would be painful if I will have to rewrite whole statuses, beside i would have to maintain same code on 2 different places.
Thank you.
Dorijan
If you need more functionality in your controller, you can add more actions to it. You can also do that in a resourcefull way.
On the other hand it usually is best practice to keep controllers thin.
See: ActionController
In order to make your views reusable, you should use partials.
You could make a _user_status partial.html.erb and render a single partial for a user render all of them for an admin.
Checkout: Layouts and Rendering in Rails