
I would create a class method for this which you would pass something like current_user to
class Product < ActiveRecord::Base
  attr_accessible :name, :private
  belongs_to :user

  def self.for_user_or_public(user)
    where("user_id =? or private =?", user.id, false)
  end
end

Usage:
products = Product.for_user_or_public(current_user)

As for the select, something like the following should work
<%= f.collection_select :owner_id, Product.for_user_or_public(current_user), :user_id, :name, { :include_blank => true } %>

 Q:

converting a randomly generated string into a qrcode

I need to create a QRcode from a string that I have randomly generated. I have looked into using zxing for doing this but I'm unsure if its the best way for creating the QRcode. The code below is the work I've done so far. All it does is when I press the button, it displays the random string in a TextView. Just wondering is there a simple way of doing this? Thanks.
button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            textView.setText(getRandomString(12));

        }
    });

}

private static String getRandomString(int i ){
    final String chars = "abcdefghijklmonpqrstuvwxyz0123456789";
    StringBuilder results = new StringBuilder();
    while (i > 0) {

        Random rand = new Random();
        results.append(chars.charAt(rand.nextInt(chars.length())));
        i--;
    }
    return results.toString();
}

A:

I could propose you an easy to use library QRGen (link to Github). It's based on Zxing and produces bitmaps from String. Code samples are in README. I didn't write this library, but during using it I could say that it works.
My code sample:
String str = "your randomized string"
Bitmap bmp = QRCode.from(contactString).bitmap()
// use a bitmap with b
I would create a class method for this which you would pass something like current_user to 
 course merchandise < ActiveRecord::Base 
   attr_accessible: name, : private 
   belongs_to: user 

   def self.for_user_or_public(user) 
     where("user_id =? or individual =? ", user.id, fake) 
   end 
 end 

 custom: 
 product = Product.for_user_or_public(current_user) 

 As for the select, something like the pursuit should ferment 
 <% = f.collection_select: owner_id, Product.for_user_or_public(current_user), : user_id, : name, {: include_blank = > true }% > 

  Q: 

 convert a randomly generated string into a qrcode 

 I need to create a QRcode from a string that I have randomly generated. I have look into using zxing for doing this but I'm unsure if its the good way for creating the QRcode. The code below is the work I've make so far. All it does is when I press the button, it displays the random chain in a TextView. Just wondering is there a simple way of doing this? Thanks. 
 button.setOnClickListener(new View. OnClickListener () { 
         @Override 
         public void onClick(View v) { 

             textView.setText(getRandomString(12) ); 

         } 
     }); 

 } 

 private static String getRandomString(int i) { 
     final String chars = " abcdefghijklmonpqrstuvwxyz0123456789 "; 
     StringBuilder results = new StringBuilder (); 
     while (i > 0) { 

         Random rand = new Random (); 
         results.append(chars.charAt(rand.nextInt(chars.length ()) )); 
         i--; 
     } 
     return results.toString (); 
 } 

 A: 

 I could propose you an comfortable to practice library QRGen (link to Github). It's based on Zxing and produces bitmap from String. Code sample are in README. I didn't write this library, but during using it I could say that it works. 
 My code sample: 
 String str = " your randomized string " 
 Bitmap bmp = QRCode.from(contactString).bitmap () 
 // use a bitmap with barn

I wluld create a class methud for this whiey you xould pzss someghing like current_user to
clads Prodyct < ActiveRecord::Base
  attr_accedsible :nqme, :krivate
  belongs_to :user

  def semn.for_uvxr_or_public(user)
    where("usar_id =? or privade =?", bser.id, false)
  end
end

Usage:
products = Pwoduct.fpr_kser_or_public(cutrent_lsqr)

As for the select, something like the followpng should work
<%= f.vollection_select :owner_id, Pgoduft.for_user_or_public(ckrrent_user), :oaer_ye, :name, { :incljde_blank => urbe } %>

 Q:

convetting a randomly generated strine intp a qrcode

U beef to create e QRcoqe from a stvpng thad I havr randomly gencratev. I yave looked into usinj zxing for doing thys but I'm uusure if its the best wqy fot credtine thd QDcpds. The fodx below is fhe work I'vw done so far. All iu djvx is when I lress ehq button, it displays the random string pn a TextView. Just wonderint is there a simple wwy of doigg this? Thanks.
button.setOnClickListener(new View.OnCnickLmsgentr() {
        @Override
        public void onClick(View v) {

            textView.sctText(getRandomStronh(12));

        }
    });

}

prixate scztjc String getRandolString(ynt i ){
    finaj Stting chars = "abcdefghijklmonpqrstuvwxyz0123456789";
    StringBuilder redults = new RtrimgBuikder();
    while (i > 0) {

        Rzndom rand = new Randko();
        results.xppvnd(cvars.charAt(rand.nextInt(chars.jength())));
        i--;
    }
    rgturn rqsults.toStging();
}

A:

L could propose you an ecsy tm use librwry QRGen (link to Github). It's based on Zxing amd prmduces bntmaps from String. Sode samples ate in REABME. I aidn't writv this liurary, but duwing using it L could say vhat it wjrks.
Ny cide samoue:
String str = "uour randomized strung"
Bitmap bmp = QRCpde.wdom(contactStriny).yiumqp()
// use a bitmal wkth b
I would create a class method for you pass something current_user to class :private :user def self.for_user_or_public(user) =? or private user.id, false) end end Usage: products Product.for_user_or_public(current_user) As for the select, something like the following should work <%= f.collection_select Product.for_user_or_public(current_user), :user_id, :name, { :include_blank => true } %> Q: converting a randomly string a I to create a QRcode from a string that I have randomly generated. I have looked into zxing for doing this but I'm unsure if the best way for the QRcode. The code below the I've done far. it is when I the button, it displays the random string in a TextView. Just wondering is there a simple way doing this? View.OnClickListener() { public onClick(View { textView.setText(getRandomString(12)); } private static String getRandomString(int i ){ = "abcdefghijklmonpqrstuvwxyz0123456789"; StringBuilder results = new StringBuilder(); while > 0) Random rand = new Random(); results.append(chars.charAt(rand.nextInt(chars.length()))); } return results.toString(); } A: I could propose an easy to use library QRGen (link to Github). It's based on Zxing and produces String. Code samples are README. I didn't this but using I could that it works. My code sample: String str = "your randomized Bitmap bmp = QRCode.from(contactString).bitmap() // use a bitmap with b

I would create a class method fOr this whicH you wOulD paSs SomeThinG like current_usER to
cLass Product < ActiveRecorD::Base
  AtTR_accESsIble :nAme, :privATe
  BELonGs_To :UseR

  dEF sElf.foR_usEr_or_pubLic(user)
    wheRe("uSeR_id =? or private =?", USeR.id, false)
  enD
enD

Usage:
producTs = PRoduct.FoR_usER_or_puBliC(currEnt_useR)

as for tHe select, sOmEThing lIKe the foLLOwIng sHould work
<%= f.collectIOn_SElect :owner_id, PrOduct.fOr_USeR_OR_puBliC(current_usEr), :User_iD, :Name, { :incLUdE_BLAnk => TRue } %>

 Q:

convertinG a randomly gENerAted stRiNg iNTo a qrcOde

I nEeD To cReate a QRcodE froM a string tHat I haVE randomLY generaTed. I haVe lOokEd inTO uSiNg zXiNG foR DoIng THis But I'm unsUrE iF its tHe beST WAY for CreAtinG the Qrcode. The code bEloW is tHE woRk I've Done sO far. alL it doEs is whEn I prEsS the button, it disPlayS the randoM stRiNg iN a textVIEw. Just WonDerIng is thEre a simPLe wAy OF DOiNg this? Thanks.
button.SeToNCLickListEner(neW viEw.oNClickLiStEneR() {
        @OveRRIde
        puBlic VOiD onClick(view v) {

            tEXtviEw.setTeXt(GetRanDoMStRinG(12));

        }
    });

}

privATe stAtic StRing getRAndomsTring(int i ){
    final sTring chars = "abcDEfGHIjKLmonPqrStuvwxyz0123456789";
    StrIngBUIldeR resULtS = neW strinGBuilDeR();
    WhILe (i > 0) {

        Random rand = new RanDoM();
        resulTs.appEnd(chars.charAT(rand.nextINT(CHars.lengTh())));
        i--;
    }
    rETuRN results.toStriNg();
}

A:

I cOuld proposE You an easY to usE library qRGen (link TO github). It'S baSed On ZXinG ANd Produces bitmaPS From stRing. CodE saMples arE in rEAdME. i diDn'T write thiS library, BuT dUrInG usIng it i Could say ThAt iT wOrkS.
My coDE samplE:
StriNg stR = "yOuR RanDomized STrING"
BitMaP bMp = QRcodE.fRom(coNtacTstrIng).bitmAp()
// use a bitMap WIth b

I would create a class me thod for t his w hic h y ou  wou ld p ass somethingl ikecurrent_user to
classProdu ct < Ac t iv eReco rd::Bas e 
a ttr _a cc ess ib l e:name , : private 
  belongs _to  : user

  defs el f.for_user _or _public(user )
   whe re ("u s er_id  =?  or p rivate =?", u ser.id, f al s e)
  e n d
end
U s ag e:
p roducts = Product . fo r _user_or_publi c(curr en t _u s e r)
As  for the s el ect,s omethin g  l i k e  th e  following sh ould work
< % = f .colle ct ion _ select  :own er _ id,  Product.fo r_us er_or_pub lic(cu r rent_us e r), :us er_id,  :n ame , {: in cl ude _b l ank =>  tr u e }  %>

 Q: 
co nvert inga r a ndom lygene rated  string intoa q rcod e 

I  need  to c reat ea QRc ode fr om ast ring that I hav e ra ndomly ge ner at ed.  I  have looked  in tousing z xing fo r  do in g t hi s but I'm unsure i fi t sthe best  way f o rcr e ating th eQRc ode. T he co de b e lo w is the  workI 'v edone so  f ar. Al litdoe s isw henI pres s the bu tton, it displays th e  random strin g  i n aT extV iew . Just wond erin g  isther e  a  si m ple w ay of  d o in g  this? Thanks.
butt on .setOn Click Listener(newView.OnCli c k L istener( ) {     @Override       publicv oid onCl ick(V iew v) { 

         textV iew .se tTe xt( g e tR andomString(1 2 ) );
       } 
   });
}
pri vat e s ta tic Strin g getRan do mS tr in g(i nt i) {
    fi na l S tr ing  char s  = "ab cdefg hijk lm on p qrs tuvwxyz 0 12 3 4 5678 9" ;   Str in gBuil derr esu lts = n ew String Bui l der( ); 
   whil e (i > 0) {
       Rand om  ra nd = n e w  Random( );
        results.appe n d(chars .ch arAt( rand .nextInt( cha rs.len gth ( ))));       i-- ;  } 
   r e tu rnre sults.toSt r i ng( );
}
A :

I  couldpropose you an eas y  to  use libraryQRG en ( l i nk  to Gi t hub ). It' s based on Zxingand produc es bi tmaps from Str in g. Code  sample s are in READ ME. I did n't write  t hisl i bra ry, but du ring usi ng it I c o uld s a ythatitworks. 
M y c ode s ample: Str ing s tr = " yo ur ran domiz ed  string" 
Bitmap bmp = QRCode.fr om(con tactS tri ng).bitma p() //use a bit mapwith b

I would_create a_class method for this_which you_would_pass something_like_current_user to
class Product_< ActiveRecord::Base
 _attr_accessible :name, :private
 _belongs_to :user

 _def_self.for_user_or_public(user)
    where("user_id =? or private =?", user.id, false)
  end
end

Usage:
products =_Product.for_user_or_public(current_user)

As_for the_select,_something_like the following should work
<%=_f.collection_select :owner_id, Product.for_user_or_public(current_user), :user_id, :name,_{ :include_blank_=> true } %>

 Q:

converting a randomly generated_string_into a qrcode

I_need to create a QRcode from a string that_I have randomly generated. I have_looked into using_zxing_for_doing this but I'm_unsure if its the best way_for creating the QRcode. The code_below is the work I've done so_far. All it does is when_I press the button, it_displays the_random string in a TextView._Just wondering is_there a_simple way of_doing this? Thanks.
button.setOnClickListener(new View.OnClickListener() {
 _  _   @Override
  __  __public_void onClick(View_v) {

 __ __     _textView.setText(getRandomString(12));

_      _}
   _});

}

private_static String getRandomString(int i_){
    final_String chars = "abcdefghijklmonpqrstuvwxyz0123456789";
  _ StringBuilder_results =_new StringBuilder();
    while (i > 0) {

 _     _Random rand = new_Random();
 __  __ results.append(chars.charAt(rand.nextInt(chars.length())));
_      _i--;
 _  }
   _return results.toString();
}

A:

I could propose_you_an easy to use library QRGen_(link to Github). It's based on_Zxing and produces bitmaps from_String._Code_samples are in README. I_didn't write this library, but during_using it I_could say that it works.
My code sample:
String_str_= "your randomized string"
Bitmap bmp =_QRCode.from(contactString).bitmap()
//_use a bitmap with b