OSDN Git Service

add test
[pettanr/pettanr.git] / app / controllers / application_controller.rb
index 2741dd3..79a5b24 100644 (file)
@@ -3,20 +3,40 @@ class ApplicationController < ActionController::Base
   before_filter :bf
   
   def bf
-    if Admin.count.to_i == 0
+    if Admin.count.to_i == 0 or License.count.to_i == 0
       if params[:controller] == 'system' and params[:action] == 'start'
       else
         redirect_to :controller => '/system', :action => 'start'
       end
     else
-      if author_signed_in?
-        @artist = if current_author.artist?
-          current_author.artist
+      if user_signed_in?
+        @user = current_user
+        @author = @user.author
+        @artist = if @author and @author.artist?
+          @author.artist
         else
-          Artist.new author_id: current_author.id, email: current_author.email, name: current_author.name
+          Artist.new author_id: @author.id, email: @user.email, name: @author.name, default_license_id: 1
         end
       end
     end
   end
   
+=begin
+  rescue_from ActiveRecord::RecordNotFound, :with => :render_404\r
+\r
+  private\r
+  def render_404(exception = nil)\r
+    if exception\r
+        logger.info "Rendering 404: #{exception.message}"\r
+    end\r
+    respond_to do |format|
+          format.html { \r
+    render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false\r
+}
+          format.json { 
+    render :text => "404 found", :status => 404\r
+}
+  end\r
+  end\r
+=end  \r
 end