Search Results

Search found 24 results on 1 pages for 'fenec'.

Page 1/1 | 1 

  • Ruby Rss parser and event trigger

    - by fenec
    I'm using RSS library so i can parse Atom and RSS in Ruby and Rails and store it in a model. I've looked at the standard RSS library, but is there one library that will auto-detect that there is a new rss feed so i can update my database ? what are the best practice to trigger an instruction in order to store the new rss feed ? should i use threads to handle that problem ?is it going to be slow? thank you for your help

    Read the article

  • rails migration version number and new model object crazy id.

    - by fenec
    hello, i have this crazy label for each time i create a migration that use the time instead of a integer. it makes things very hard to switch between the version of the database that you want to use. i also have this crazy ID for each object that i create : How can set up rails to have easy version and id numbers. thank you

    Read the article

  • rails when to use self.

    - by fenec
    i am developing a rails application and would like to understand when do we use self.for . here is the code of a method that i would like to fully understand.if it is possible i would like to have an alternative to this code so it would make things more clear. enter code here def self.for(facebook_id) User.create_by_facebook_id(facebook_id) end

    Read the article

  • rails dates with json

    - by fenec
    hello am implementing a facebook application and am using AJAX/Json,however the json structures that are returned have this format "2010-05-30T06:14:00Z" , I am using Game.all.to_json how can i convert them to a normal date format ? Is it easier to do it from the server side or the client side using fbjs? (there are a lot of bugs with fbjs so i would prefer using a solution from the server side , like converting the data before sending the json structures) thnak you

    Read the article

  • In Rails Can we pass a parameters to a new Action

    - by fenec
    i would like to write a message using an instince variable in the new invition action like this. redirect_to new_invitation_path("invite your friend") Controller invitations: def new(message) @message = message @from_user_id = facebook_session.user.to_s end Apparently it is not possible how can i find a way around this?

    Read the article

  • howto design an invite feature feature?

    - by fenec
    hello i am trying to implement a feature in my facebook application that would give 100 point to someone who would send 10 invitations. however i want a limit that feature for each user to use it only 10 times a day. how should i design my feature to do what i want

    Read the article

  • Ruby comparing dates

    - by fenec
    I would like to do is to know if a user has been created in the system in the last 10 second. so i would do: def new_user if(DateTime.now - User.created_at < 10) return true else return false end end IT is just an idea , how can i do it correctly? thank you

    Read the article

  • problems to setup the ruby on rails facebooker plugin

    - by fenec
    i am developing a facebook application with rails and the facebooker plugin from my local machine and have problems to set it up. here is my facebooker.yml file enter code here development: api_key: myAPIKey secret_key: mySecretKey canvas_page_name: http://apps.facebook.com/rafikbennacer/ callback_url: http://207.172.82.237:3000 pretty_errors: true set_asset_host_to_callback_url: true tunnel: public_host_username: public_host: public_port: 4007 local_port: 3000 server_alive_interval: 0 I got my Callback URL accessible from the outside by doing a port forwarding on my router, everything seems to work but i still have this message error when i go to http://apps.facebook.com/rafikbennacer/: Errors while loading page from application Received HTTP error code 404 while loading http://207.172.82.237:3000/ Please try again later. We appreciate your patience as the developers of test1 and Facebook resolve this issue. Thanks! where am i wrong in my configuration , how can i trouble shoot this error? thank you

    Read the article

  • is an instance variable in an action of a controller available for all the controllers view?

    - by fenec
    I am just trying to printout the parameters that have been entered into my form. basically i create a new bet then i display the parameters: MIGRATION enter code here class CreateBets < ActiveRecord::Migration def self.up create_table :bets do |t| t.integer :accepted ,:default = 0 t.integer :user_1_id #proposer t.integer :user_2_id #receiver t.integer :team_1_id #proposer's team t.integer :team_2_id #receiver's team t.integer :game_id t.integer :winner t.integer :amount t.timestamps end end def self.down drop_table :bets end end CONTROLLER bets_controller.erb enter code here class BetsController < ApplicationController def index redirect_to new_bet_path end def new @b=Bet.new end def create @@points=params[:points] @@winner=params[:winner] end end VIEWS New.erb New Bet <% facebook_form_for Bet.new do |f| %> <%= f.text_field :amount, :label=>"points" %> <%= f.text_field :winner, :label=>"WinningTeam" %> <%= f.buttons "Bet" %> <% end %> create.erb enter code here points:<%= @@points %> <br> winner:<%= @@winner %>

    Read the article

  • ruby on rails one-to-many relationship

    - by fenec
    I would like to model a betting system relationship using the power of rails. so lets start with doing something very simple modelling the relationship from a user to a bet.i would like to have a model bet with 2 primary keys. here are my migrations enter code here class CreateBets < ActiveRecord::Migration def self.up create_table :bets do |t| t.integer :user_1_id t.integer :user_2_id t.integer :amount t.timestamps end end def self.down drop_table :bets end end class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.timestamps end end def self.down drop_table :users end end the models enter code here class Bet < ActiveRecord::Base belongs_to :user_1,:class_name=:User belongs_to :user_2,:class_name=:User end class User < ActiveRecord::Base has_many :bets, :foreign_key =:user_1) has_many :bets, :foreign_key =:user_2) end when i test here in the console my relationships I got an error enter code here u1=User.create :name="aa" = # u2=User.create :name="bb" = # b=Bet.create(:user_1=u1,:user_2=u2) *****error***** QUESTIONS: 1 How do I define the relationships between these tables correctly? 2 are there any conventions to name the attributes (ex:user_1_id...) thank you for your help

    Read the article

  • cant use Activerecord find method with associations.

    - by fenec
    here are my models: #game class Game < ActiveRecord::Base #relationships with the teams for a given game belongs_to :team_1,:class_name=>"Team",:foreign_key=>"team_1_id" belongs_to :team_2,:class_name=>"Team",:foreign_key=>"team_2_id" def self.find_games(name) items = Game.find(:all,:include=>[:team_1,:team_2] , :conditions => ["team_1.name = ?", name] ) end end #teams class Team < ActiveRecord::Base #relationships with games has_many :games, :foreign_key =>'team_1' has_many :games, :foreign_key =>'team_2' end When i execute Game.find_games("real") i get : ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: team_1.name How can i fix the problem i thought that using :include would fix the problem.

    Read the article

  • will_paginate and facebook/facebooker

    - by fenec
    I'm using will_paginate in a facebook application and when i click on the next button or a page number i get the url below. This is fine if everyone was using safari, but it breaks on ie and ff. That and people can't copy and paste the url to others. Anyone have any ideas how to fix this. http://apps.facebook.com/application/users/4785/votes.fbml?_method=GE... URL TOO BIG

    Read the article

  • how to user ajax with json in ruby on rails

    - by fenec
    I am implemeting a facebook application in rails using facebooker plugin, therefore it is very important to use this architecture if i want to update multiple DOM in my page. if my code works in a regular rails application it would work in my facebook application. i am trying to use ajax to let the user know that the comment was sent, and update the comments bloc. migration: class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.string :body t.timestamps end end def self.down drop_table :comments end end controller: class CommentsController < ApplicationController def index @comments=Comment.all end def create @comment=Comment.create(params[:comment]) if request.xhr? @comments=Comment.all render :json=>{:ids_to_update=>[:all_comments,:form_message], :all_comments=>render_to_string(:partial=>"comments" ), :form_message=>"Your comment has been added." } else redirect_to comments_url end end end view: <script> function update_count(str,message_id) { len=str.length; if (len < 200) { $(message_id).innerHTML="<span style='color: green'>"+ (200-len)+" remaining</span>"; } else { $(message_id).innerHTML="<span style='color: red'>"+ "Comment too long. Only 200 characters allowed.</span>"; } } function update_multiple(json) { for( var i=0; i<json["ids_to_update"].length; i++ ) { id=json["ids_to_update"][i]; $(id).innerHTML=json[id]; } } </script> <div id="all_comments" > <%= render :partial=>"comments/comments" %> </div> Talk some trash: <br /> <% remote_form_for Comment.new, :url=>comments_url, :success=>"update_multiple(request)" do |f|%> <%= f.text_area :body, :onchange=>"update_count(this.getValue(),'remaining');" , :onkeyup=>"update_count(this.getValue(),'remaining');" %> <br /> <%= f.submit 'Post'%> <% end %> <p id="remaining" >&nbsp;</p> <p id="form_message" >&nbsp;</p> <br><br> <br> if i try to do alert(json) in the first line of the update_multiple function , i got an [object Object]. if i try to do alert(json["ids_to_update"][0]) in the first line of the update_multiple function , there is no dialog box displayed. however the comment got saved but nothing is updated. questions: 1.how can javascript and rails know that i am dealing with json objects? 2.how can i debug this problem? 3.how can i get it to work?

    Read the article

  • rails howto use environment constant in models and views?

    - by fenec
    i have my constants initialized in environment.rb like this : Rails::Initializer.run do |config| ... MAX_BID = 10 end i would like to use this constant in my models and views,what is the correct syntax? if a use it a model its says NameError: uninitialized constant User::MAX_BID i understand that it is looking for the constant inside the model , how can i tell explicitly that this constant is in the environment? thanks

    Read the article

  • rails howto compare datetime ?

    - by fenec
    hello, i have games in my sqLite DB with the attribute starting_date( t.date :starting_date). i would like to know all the games that have alreday started so i am using this lines of code: Game.find :all,:conditions=>"starting_date <= #{Date.today}" Game.find_by_sql("SELECT * FROM "games" WHERE (created_at < 2010-05-13)") the result is nill,even though i know that i have games that have already started like this one : #<Game id: 1, team_1_id: 2, team_2_id: 1, status: 2, team_1_points: nil, team_2_points: nil, starting_date: "2010-05-05", winner: 1, sport: "football", country: nil, league: "calcio", created_at: "2010-04-07 00:09:21", updated_at: "2010-05-13 00:57:19"> what am i doing wrong here?

    Read the article

  • howto have condition in a nested SQL query?

    - by fenec
    here is my SQL statement , i would like to find all the games that have the status 0 and names of teams that are like key_word or the sport's name that are like the key word. The problem is that all the games that are displayed don't have status 0 . What am i doing wrong? sql="select * from games where games.status=0 and games.team_2_id IN (select id from teams where name like '"+key_word+"') or games.team_1_id IN (select id from teams where name like '"+key_word+"') or games.sport like '"+key_word+"' "

    Read the article

1