Posts

ruby on rails - has_one association isn't working -

i have following activerecord models: class user < activerecord::base has_one :faculty end class faculty < activerecord::base belongs_to :head, class_name: 'user', foreign_key: :user_id end when try pull user using association faculty.head record without errors, when type user.faculty error: faculty load (1.8ms) select "faculties".* "faculties" "faculties"."user_id" = 1 limit 1 activerecord::statementinvalid: pg::undefinedfunction: error: operator not exist: character varying = integer line 1: ...".* "faculties" "faculties"."user_id" = 1 limit ... my faculties db schema looks this: create_table "faculties", :force => true |t| t.string "name" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.string "user_id" end is pg bug?? the error occurs because hav...

Elegant way to search (PHP + MySQL) -

we have website written in codeigniter framework. want have nice , fast soundex based search function site. it's micro blog search in titles of posts. so best us? i have 2 ideas: create column in post table soundex copy of title , have full-text index on it. explode words titles , save soundex equivalent of words in new table id of post. automatic tag system. which method better , why? can suggest better way? thanks answers! soundex great - doesn't meet user expectations search (established google etc.). the common solution text searching, including fuzzy searches , stemming, use solr ; it's relatively easy integrate php using web service calls. the zend framework has lucene integration (never used it, might save time) - lucene open source free text search platform .

Two level loop over a matrix's row in R -

i need convert iteration below matrix operation. a = certain_matrix(3,5) mat = matrix(0, 3,3) ( in 1:3 ) ( j in 1:3 ) mat[i,j] = certain_distance(a[i,], a[j,]) roughly need use apply(). however, cannot hold of row index in apply(a, 1, function(x) xxx) so how perform operation fast?

ruby on rails - error when updating whilst using acts-as-taggable -

good morning everyone, i've been stumped error days or 2 now. my app small "sample request log" textiles based company, needs track samples , able edit/submit/delete them. whenever try update or create new request "undefined method `each' "x":string" x option chosen in drop down list (the drop down list populated controller.) request_controller.rb: class requestscontroller < applicationcontroller before_action :set_request, only: [:show, :edit, :update, :destroy] # /requests # /requests.json def index if params[:tag] @requests = request.tagged_with(params[:tag]) else @requests = request.all @requests = request.order("request_date asc") end end # /requests/1 # /requests/1.json def show end # /requests/new def new @request = request.new @customers = customer.all @suppliers = supplier.all @designers = designer.all @statuses = status.all end # /requests/1/edit def edit ...

SoapUI- Is it possible to create a Mock service from a sample oData call? -

is possible create mock service sample odata call in soapui? (without wsdl) you can try below sample: http://www.soapui.org/getting-started/rest-sample-project.html cheers...

Set raw resource as ringtone in Android -

in android application, want set audio file raw folder ringtone. wrote below code, not working. please me solve issue. thank you. code : string name =best_song_ever.mp3; file newsoundfile = new file("/sdcard/media/ringtone", "myringtone.mp3"); uri muri = uri.parse("android.resource://" + context.getpackagename() + "/raw/" + name); contentresolver mcr = context.getcontentresolver(); assetfiledescriptor soundfile; try { soundfile = mcr.openassetfiledescriptor(muri, "r"); } catch (filenotfoundexception e) { soundfile = null; } try { byte[] readdata = new byte[1024]; fileinputstream fis = soundfile.createinputstream(); fileoutputstream fos = new fileoutputstream(newsoundfile); ...

design - General rules for detemining which models/controllers one needs when building a Rails app -

i rails newbie. had @ different tutorials , books. 1 common thing teach different aspects of rails following step-by-step guide on building simple app. shows how things. however, more interested in following question - if know app should in terms of features , does, how determine models/controllers need? mean, in tutorials tell you, example, build users model, posts model , comments model (if it's blog app), how know upfront need these models? there general rules when unit of application should become model vs. keeping part of existing model? a brief example: want build enterprise voting app, each user can assigned 1 or more shareholders , take part in general meetings each meeting containing several agenda items, can vote on. o.k., need user model/controller, maybe shareholders model, meetings model , questions model, how figure out if need other models? the quick answer there no general rules this. it idea sit down pen , paper , sketch out application objects , ...