Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Felipe - IMAGINIS

[Resolvido] Erro kEND

Recommended Posts

Pessoal, estou com um problemão e nao sei resolver.

 

Na verdade eu não se praticamente nd de rails e o meu programador sumiu.

 

o erro está no model.

 

class User < ActiveRecord::Base
  has_paper_trail :ignore => [:last_seen_at, :current_login_at, :last_login_at, :updated_at, :reseting_password, :salt, :crypted_password, :persistence_token, :created_at, :posts_count] 
  acts_as_authentic do |config|
    config.crypto_provider = Authlogic::CryptoProviders::MD5
  end
  include SavageBeast::UserInit
  
  #Attributes
  attr_accessor :photo_updated_at

  #Associations
  belongs_to :group
  has_many :feeds_users, :dependent => :delete_all
  has_many :feeds, :through => :feeds_users
  has_many :errands, :dependent => :delete_all
  has_many :published_newsletters, :class_name => 'Newsletter'
  has_many :published_forms, :class_name => 'Form'
  has_many :published_financial_informations, :class_name => 'FinancialInformation'
  has_many :published_ideias, :class_name => 'Ideia'
  has_many :published_tidings, :class_name => 'Tiding'
  has_many :photo_albums
  
  has_many :blog_posts
	has_many :blog_comments
  
  #Validations
  validates_presence_of :login, :name
  validates_presence_of :password, :password_confirmation, :unless => Proc.new {|user| user.password.blank? && user.password_confirmation.blank?}
  #validates_uniqueness_of :email
  validates_format_of :email,
                      :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, 
                      :message => 'inválido'
  validate :trying_use_previous_password_again, :on => :update, :unless => Proc.new {|user| user.password.blank?}
  
  #Attachments
  has_attached_file :photo, 
                  :styles => { :original => ['525x395'], :thumb => ['80x85'], :mini => ['53x50#']},
                  :url => "/attachments/:class/:id/:attachment/:style.:extension",
                  :path => ":rails_root/public/attachments/:class/:id/:attachment/:style.:extension",
                  :default_url => "/attachments/:class/:style_missing.png"
  
  #Named scopes
  named_scope :no_deleted, :conditions => {:is_deleted => false}
  
  
  #Class methods
  def self.find_by_login_no_deleted(login)
    find_by_login(login, :conditions => {:is_deleted => false})
  end
  
  #Instance methods
  def to_s
    name
  end
  
  def to_param
    "#{id}-#{name.parameterize}"
  end
  
  def trying_use_previous_password_again
    errors.add(:password, "Você não pode usar a mesma senha que foi alterada pelo sistema, tente uma nova senha.") if  User.crypto_provider.encrypt([password, previous_salt].compact) == previous_password
  end
  
  def reset_and_notify_new_password!
    User.transaction do
      update_attributes :reseting_password => true, :previous_password => crypted_password, :previous_salt => salt
      reset_password!
      Notifier.deliver_password_reset(self)
      update_attribute :reseting_password, false
    end
  end
  
  def can_manager_users?
    group.name == 'Sócios'
  end
  
  def can_manager_user(user)
    self == user || self.is_admin? || (self.can_manager_users? && !user.can_manager_users?)
  end
  
  def is_admin?
    is_admin
  end
  
  def update_feeds
    unless feeds.empty?
      dup_feeds = []
      all_feeds = []
      feeds.each do |feed|
        if all_feeds.include? feed.url
          dup_feeds << feed
        else
          Entry.update_from_feed feed.url
          all_feeds << feed.url
        end
      end
      dup_feeds.each do |feed|
        FeedsUser.find(:first, :conditions => { :feed_id => feed.id }).destroy      
      end
    end
  end
  
  def display_name
    login
  end
  
  def admin?
    true
  end
  
  def currently_online #to remove
    false
  end
	
	# Implement in your user model 
	def display_name
		name
	end
	
	# Whether a user can post to a given blog
	# Implement in your user model
	def can_blog?(blog_id = nil)
		# This can be implemented however you want, but here's how I would do it, if I were you and I had multiple blogs, 
		# where some users were allowed to write in one set of blogs and other users were allowed to write in a different 
		# set:
		# Create a string field in your user called something like "blog_permissions", and keep a Marshaled array of blogs 
		# that this user is allowed to contribute to.  Ezra gives some details on how to save Marshaled data in Mysql here:
		# http://www.ruby-forum.com/topic/164786
		# To determine if the user is allowed to blog here, call up the array, and see if the blog_set_id
		# is contained in their list of allowable blogs. 
		#
		# Of course, you could also create a join table to join users to blogs they can blog in.  But do you want to do 
		# that with blog comments and ability to moderate comments as well?
		true
	end
	
	# Whether a user can moderate the comments for a given blog
	# Implement in your user model
	def can_moderate_blog_comments?(blog_id = nil)
		true
	end
	
	# Whether the comments that a user makes within a given blog are automatically approved (as opposed to being queued until a moderator approves them)
	# Implement in your user model, if you care.
	def blog_comment_auto_approved?(blog_id = nil)
		true
	end
	
	# Whether a user has access to create, edit and destroy blogs
	# Implement in your user model
	def can_modify_blogs?
	  if Blog.all.empty?
	    true
    else
  		false
		end
	end
	
	# Implement in your user model 
#	def logged_in?
#		current_user && true
#	end
	
	# The path to your user's avatar.  Here we have sample code to fall back on a gravatar, if that's your bag.
	# Implement in your user model 
	def blog_avatar_url
		if(self.respond_to?(:email))
			downcased_email_address = self.email.downcase
			hash = MD5::md5(downcased_email_address)
			"http://www.gravatar.com/avatar/#{hash}"
		else
			"http://www.pistonsforum.com/images/avatars/avatar22.gif"
		end
	end
end

ele diz q o problema está na linha syntax error, unexpected kEND, expecting $end

 

agradeço a atenção.

Compartilhar este post


Link para o post
Compartilhar em outros sites

se não me engano esse erro quer dizer que em algum lugar está faltando um END

Compartilhar este post


Link para o post
Compartilhar em outros sites

O erro pode estar aqui:

 

def update_feeds

unless feeds.empty?

dup_feeds = []

all_feeds = []

feeds.each do |feed|

if all_feeds.include? feed.url

dup_feeds << feed

else

Entry.update_from_feed feed.url

all_feeds << feed.url

end

end

dup_feeds.each do |feed|

FeedsUser.find(:first, :conditions => { :feed_id => feed.id }).destroy

end

end

end

 

Aparentemente esta sobrando um END...qual a linha do erro?

 

Abraço

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.