public
Description: Store translation strings in the database allowing you to update text without requiring a code deploy.
Clone URL: git://github.com/caring/gibberish_db.git
gibberish_db / ext / gibberish_controller.rb
100644 28 lines (25 sloc) 0.898 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class GibberishController < ApplicationController
  # Probably don't want everyone to do this
  # access_control [:edit, :save] => '(admin | editor | copyeditor)'
  
  # uncomment if you've got ssl pages
  # ssl_allowed :edit, :save if RUN_SSL == true
  
  def edit
    @translation = Gibberish::Translation.find_cached_by_language_and_key(
      Gibberish::Language.find_cached_by_name(params[:lang]),
      params[:id])
    render :text => @translation.value
  end
  
  def save
    @translation = Gibberish::Translation.find_cached_by_language_and_key(
      Gibberish::Language.find_cached_by_name(params[:lang]),
      params[:id])
    if params[:value].blank?
      @translation.destroy
      render :text => "reload the page to see the default value again"
    else
      @translation.value = params[:value]
      @translation.save!
      render :text => @translation.value
    end
  end
end