I have established a @ release like a Twitter that allows users to contact each other through daily post Is ... similar to Stakeoverflow
Using it as a guide
  How can I pars / scan a post &; Then change the copy of the @username with the user names      Example of a post.     I have to scan / pars me posts And then users want to link @Progress @ Johns @Stest to their profile     I tried to make a method in my DailyPost model, which stores usernames in an array .... but how to convert them to idk and link to the appropriate users page     This gives me ["@pressation", "@Johns" , "@ Steve"] gives    please help me .... New to Rail :)     Model      SCHEMA      VIEWS     <%> link     You can pass each match through a block. In this block, you return the necessary links, such as something     edit     Supporting functions in postcodeontent_html.gsub (/ @ \ w + /)   use it in your view  < Pre>  
 Kevins Post: @Pzpcreations  
 deaf user_man_link str = self.content_html recipient = end of SRNC (USERNAME_REGEX)    
 
 create_table "recipient",: force => Is true T | T.string "user_id" t.string "dailypost_id" t.datetime "created_at" ,: null = & gt; Incorrect t.datetime "updated_at" ,: null = & gt; False end [# & lt; Recipient ID: 7, ** User_id: "103" **, DailyPost_ID: "316", Created_TA: "2013-06-18 10:31:16", updated_at: "2013-06-18 10:31:16 "& Gt;] The recipients are user_id users who are described in the dailypost.     
 def username_link str = self.content_html str.gsub! (USERNAME_REGEX) .each do | Recipient | If user.find_by_name (recipient) "[link to # {recipient}]" and end of receiver ending    apps / helpers / post_helpers.rb    
 def post_with_links (post) Each user name. User = User.find_by_username (username. [1 ..- 1]) If user link_to username, user other user name expiry    & lt;% = post_with_links (post)% & gt;    
 
No comments:
Post a Comment