Posts

How to raise a custom Exception in Rails 3+ with normal control flow? -

given following controller method: def create @client = user.find(params[:client][:id]) respond_to |format| if @client.present? && @client.add_manager(current_user) format.html { redirect_to clients_path, notice: "successfully added manager" } else format.html { redirect_to clients_path, error: "could not find client" } end end end how fail in else block instead of throwing runtimeerror turns "something went wrong" on production? def add_manager(user) raise "already manager" if self.manager_users.include?(user) self.manager_users << user if user.trainer? end is code... you can try this: in controller class yourappname::alreadymanagererror < standarderror end now change "already manager" name of custom error def add_manager(user) raise yourappname::alreadymanagererror if self.manager_users.include?(user) self.manager_users ...

html - Drop Down IE 8 and Below Not Working -

hi finished redesigning site include drop down menus, learned today ie 8 , below don't display them near correctly. displays fine knowledge on every other browser. don't know i've gone wrong, i've been debugging , haven't been able figure out. any appreciated! here jsfiddle html , css: http://jsfiddle.net/sctqy/ here link live site: http://www.hearditfrom.com (this in js fiddle) here html/php: <nav id="hb2_nav"> <ul> <li><a class="hb2_nav" href="category.php">categories <span class="arrow-down"></span></a> <ul class="drop-shadow"> <span class="category_column"> <li><a href="category.php?category=1">u.s.</a></li> <li><a href="category.php?category=2">world</a></li> <li><a href="category.php?category=3">busines...

c - 2 FIFOs 1 Task - Synchronize them -

i have following problem: i have launch process various terminals can start running program after number of processes has started. in other words, have block somehow processes until right number of processes. i'm trying using fifos using first process called "server". problem resumed ticket entrance problem: "server" process writing in fifo number of next process. next process take "ticket" , send "server" number++. coded this, basically: server: count = 0; fd_w = open ("client", o_wronly); fd_r = open ("server", o_rdonly); { write (fd_w, &count, sizeof(int)); //write on client's reading fifo read (fd_r, &count, sizeof(int)); //read clients wrote printf ("msg read: %d\n", count); } while (count != 4); printf ("starting...\n"); client: fd_r = open ("client", o_rdonly); fd_w = open ("server", o_wronly); read (fd_r, &count, sizeof(int)); //...

android - TabWidget will not display, even though it displays in ADT editor -

Image
my tabwidget not display, though shows in eclipse graphical editor. can't find reason why. why isn't tab bar showing? eclipse emulator xml source of activity: http://pastebin.com/au9xfxpa extract activity: <tabwidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" > </tabwidget> results android lint: $ lint.bat res/layout/activity_calculator.xml scanning catalyst: . no issues found. it's hard tell without actual code of how activity implemented, seems need call setcontent() on tabhost : tabhost tabs = (tabhost)findviewbyid(r.id.tabhost); tabs.setup(); // calculator tabhost.tabspec calculatortab = tabs.newtabspec("calculator"); calculatortab.setcontent(r.id.calculator); calculatortab.setindicator("calculator"); tabs.addtab(calculatortab); // ...

php - Compilation failed: unmatched parentheses at offset -

i writing regular expression, when check following regex online, works correctly. however, return error in php. why that? preg_match_all('/^[([a-z]+\[[a-z| |,]+\])\,?]+$/', $methods, $result); return severity: warning message: preg_match_all() [function.preg-match-all]: compilation failed: unmatched parentheses @ offset 23 i tried 1 too: preg_match_all('/^[([a-z]+\\[[a-z| |,]+\\])\\,?]+$/', $methods, $result); if change outer character class ( [] ) character group (parentheses) compile, im not sure kind of string trying match: /^(([a-z]+\[[a-z| |,]+\])\,?)+$/ like in example i think caused because cant put nested character class because lose meaning regex ends in 3 parts this: [([a-z]+ \[[a-z| |,]+ \])\,?]+ ending in unmatched enter parentheses

.net - Show icons corresponding to the file type in asp.net -

Image
i need show icons corresponding file type. example have "sample.doc" in string, show in anchor tag link make downloadable. link have file name shown below <a title="sample" target="_blank" href="\files\sample.doc">sample</a> what need want link shown below there many filetypes require show on web page. how can achieve this. starting point me continue it. i (pseudo-code) foreach(var file in files){ var extension = path.getextension(file) ... <a title="sample" target="_blank" href="\files\sample.doc"> <img src="/images/@(extension).png" /> sample </a> }

browser - Vaadin request processing per http session -

am using vaadin 6.8. though below link describes how vaadin supports multiple browser tab, https://vaadin.com/web/joonas/wiki/-/wiki/main/supporting%20multible%20tabs tabs of same browser using same http session , hence same application instance. however, tabs use different window objects there giving illusion of multi tab support. but, vaadin locks application instance while processing httprequests (specially updateuidl calls). http requests given session processes serially. until tab1 request processed completely, tab2 request not processed. so, busy loading icon shown on both tabs. abstractcommunicationmanager.dohandleuidlrequest() locks application object. anyone has workaround issue? or is there anyway force vaadin use new http session each tab or pop up?